System information
An Introduction to Shells in General
Axis Communications AB provides NO support for application development of any kind. The information
here is provided "as is", and there is no guarantee that any of the examples shown will work in your
particular application.
Revision 1.02 October 2002 40
5 An Introduction to Shells in General
A shell is a programming language that is fully equipped with:
• variables
• conditional and iterative constructs
5.1 The mish shell
The commands available in mish are essentially the same as the ones commonly used in other
shells on any Linux/Unix system, so the manual pages can often be useful. The difference is that
the commands in mish have been simplified, i.e. options have been removed. Besides these
modifications, some extra commands have been added. These are not documented as a manual
page.
The shell includes a help command, which lists the functions available in the shell.
When programming shell scripts, you must begin with the sequence #!/bin/mish, before
starting on your code. The statement after #! states the name of the program used to interpret the
code in your script.
Another good practice when programming is to add comments to your code. All comments are
preceded with the hash (#) sign.
When a shell script is created, the file will not be executable. By default, the file will be a
read/write file, and the user will not be able to run or execute it. To make a file executable, the
file permission must be changed. Use the command chmod to make a shell file executable.
5.2 Shell commands
Name
sh, ., break, case, cd, continue, eval, exec, exit, export, for,if, read, readonly,set, shift,
trap, umask, wait, while – shell
Synopsis
sh [-eiknqstvxu][-c str] [file]
Options
• -c Execute the commands in str
• -e Quit on error
• -i Interactive mode; ignore QUIT,TERMINATE, INTERRUPT
• -k Look for name=value everywhere on command line
• -n Do not execute commands
• -q Change qflag from sig_ign to sig_del
• -s Read commands from standard input
• -t Exit after reading and executing one command