Previous Table of Contents Next


Explicit Invocation

If ksh is the first word of a command, then the shell has been invoked explicitly. This allows you to pass options to the ksh program, setting up a new environment to execute a command. The general format of an explicit shell command follows.

     ksh [ options ] [ command [ options ] [ arguments ] ]

The first set of options are the ksh options listed in the Options section. The second set of options are used by the command and are described in each command-related module.

Implicit Invocation

If a shell script is executed, the current shell invokes a new ksh program that will read and execute the script. The general format of an implicit shell command follows.

     command [ options ] [ arguments ]

The options on an implicit command are used by the command; they do not control the ksh program.

For example, let's say you typed myscript parameter1 and pressed Return. Your current shell would search all directories listed in the PATH variable for a program named "myscript." If it found such a program it would check the type of contents. If the program in the file was considered to be a shell script, your current shell would execute the program by executing the ksh -c myscript parameter1 command.

RESTRICTED SHELL

The restricted shell is used to provide a controlled environment for user names who are not allowed full user access to the system. The restricted ksh (rksh) performs the same functions as the normal ksh, except the following actions cannot be performed:

*  Changing directories (refer to Module 14, cd)
*  Setting the SHELL and PATH variables to new values
*  Using command names or paths containing a /
*  Redirecting output (> and >>)

If the restricted shell is used as the login shell, then it reads all the normal setup files. After it reads the $HOME/.profile and the $ENV files it enforces the above restrictions.

If the program requested in a command is a shell script, then rksh invokes ksh to execute the script. Therefore, the restricted user can be provided with a fully functional shell. Usually, the shell script is an "end-user" type menu that controls what command the user can use. This environment assumes that the user does not have write and execute permissions in the directory that contains the shell script (menu).

This concept of restriction allows the owner of the $HOME/.profile of the restricted user to control the level of restriction. The owner is usually the system administrator, not the user who logged in to the account. The system administrator may set up a restricted bin that contains a limited set of commands that the user can access. The result is a very flexible environment for controlling system users.

SPECIAL (META) CHARACTERS

The following list defines the characters that have special meaning to the shell when it scans a command. These characters cause termination of a word unless they are quoted (refer to the Quoting section). All of these characters are highly related to commands and must be remembered to understand how commands are interpreted and function.


Special Character Description

; Sequential execution operator. It functions like a new-line; the left-hand command, preceding the ;, must complete before the right-hand command, following the ;, can be executed.
| Pipe creating operator. A pipe is created between the left-hand and right-hand command. The standard output of the left-hand command is "piped" into the standard input of the right-hand command.
& Background operator. The command preceding the & is executed asynchronously. The shell places the command in "background" mode and continues executing the next command.
|& Shell Pipe creating operator. The command preceding the |& is executed asynchronously, just as if you had used the &. The difference is the standard input and output of the new command is redirected via a two-way pipe. This two-way pipe is managed by the shell. To write to the pipe, use print -p and to read from the pipe, use read -p. The command placed in the background must be a complete filter; the first command must read from standard input and the last must write to standard output. See the example below for further explanation.
&& The logical and operator. The right-hand command is executed only if the left-hand command returns a false (nonzero) exit status.
|| The logical or operator. The right-hand command is executed only if the left-hand command returns a true (zero) exit status.
(list) The subshell operators. The command enclosed within the parentheses is executed as a subshell or child process of the current shell. Output is combined into one stream.
{list;} The grouping keywords. The command enclosed within the braces is executed in the current shell. Because the braces are keywords, a blank or new-line must follow the first one and a ; or new-line must precede the second one. For example,
                        {echo This is not valid}
whereas
                        {echo This is valid ;}
space The space character. The octal 040 or decimal 32 ASCII character. Separates words and names.
tab The tab character. The octal 012 or decimal 10 ASCII character.
new-line The new-line character or Return. The octal 015 or decimal 12 ASCII character.

C Shell
|& Pipe creating operator. A pipe is created between the left-hand and right-hand command. The standard output and standard error on the left-hand command is "piped" into the standard input of the right-hand command.

The following examples help clarify how special characters are used.


Previous Table of Contents Next