Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)
User Commands (m - o) osh(1)
Duplicating Output
[n]>&fd Duplicates output file descriptors. If the fd argument consists of
one or more digits, the file descriptor n is made a copy of file
descriptor fd.Iffd is -, file descriptor n is closed. If n is not
specified, the standard output file (file descriptor 1) is used.
The order of redirections is significant. For example, the sequence
osh -c "ls -a" >lsout 2>&1
directs both standard output and standard error to the file lsout, while the sequence
osh -c "ls -a" 2>&1 >lsout
directs only standard output to the file lsout, because the standard error file was duplicated as the
standard output file before the standard output file was redirected.
Operands
All operands that the osh command does not interpret as option or redirection arguments are
passed to the child process as positional arguments in argv[1] through argv[n]. osh does not
expand operands or interpret special characters, except that double quotes can be used to group a
set of operands into a single argument.
The character string that constitutes a single operand depends on the parsing done to the command
line. An osh command line can be parsed up to four times before being executed.
The parsers that might interpret the line are:
TACL
The C run-time initializer
The osh process
The OSS shell
Each of these parsers applies different rules for special characters and uses different characters as
escape sequences to bypass parsing. A command line that contains special characters must be
entered with the escape sequences appropriate for each of these parsers.
For example, suppose a command line is entered through the Guardian environment TACL com-
mand interpreter. The TACL process can interpret or expand operands on the command line before
passing the line to the osh command to interpret. The settings used for TACL features can affect
the outcome of the command. In the following osh command, the OSS shell pipe symbol reaches
the shell for execution if the user has #INFORMAT PLAIN in effect:
osh -c "grep ’#’include *.c | sort | unique | more"
However, the pipe symbol cannot reach the shell for execution if the user has #INFORMAT TACL
in effect because the | character has a programming function within TACL. With #INFORMAT
TACL, the appropriate command line becomes:
osh -c "grep ’#’include *.c | sort | unique | more"
In both examples, the double quotes (") prevent the C run-time initializer from dividing the com-
mand parameter value into pieces that the osh command passes on to the child process (the OSS
shell) as multiple operands. The single quotes (’) prevent the OSS shell from interpreting all char-
acters of the operand following the number sign (#) as a comment.
You can pass 980 bytes of operands to the child process.
527188-007 Hewlett-Packard Company 6−101