Open a text editor of your choice and type in the lines of the commands you wish to run.
The first line, aka as hash-bang, indicates the shell interpreter in which those commands will run. Note it is
incorrect in the cut 'n' paste job entered, it should be (with a ! included):
The bang being !.
This can be any shell/language you like, the example is the Bourne Again Shell bash. It could equally be perl, tcl, python or .. in a long list. The full path to the required shell is needed and can be determined for your particular system, prior to entering the text editor, with
or 'which perl' ... or whatever.
Make sure the script and this location agree. The lines after the '#bang' are lines of text acceptable to the shell you've just defined so, in this example, they must be valid bash.
Save the file. You might call it omxplayer.sh. Then exit the text editor. You should then see the file if you use the 'ls' command, assuming you are in the directory where you saved the script.
The type
or whatever you called the script. This allows you to run the script as a 'command' as in:
Without this you would have to type
i.e. run an instance of bash , sourcing your script into it. And you also would have to 'cd' (change directory) to where the script had been saved. This is cumbersome.
If you locate your script in a directory that is in the PATH of your login shell the you won't need to navigate to the directory, and you will be able to drop the './' bit too and simply type:
A common location is ~/bin i.e the bin sub-folder of your user directory. You can type
to determine locations that have already been included in your user PATH. Google, or search this forum, to see how to add entries to your PATH, in a manner that will survive log-outs, re-boots etc.
The location also can be seen which:
which will show the full location i.e which directory in the PATH-list the script is located. Bear in mind the 'which' command scans the PATH-list and returns the first one found, so its not the way to find arbitrary bits of code, tucked away in crooks and crannies.
The script makes the assumption that omxplayer itself is in a location that can be found i.e. its in the PATH. Type
to ensure this is the case; if which fails the script will fail. It may also fail for other users if their PATHs are different. A common method is to put the full path name to commands run within the script to ensure that it does not have an external dependency upon the users environment.
Hope this helps.
Dave