Because
Because tcsh
or bash
under UNIX) to allow
reuse of complex commands with a minimum of key strokes. Also
an available alias mechanism should be used to make life easier.
E.g. the
show
command uses velocity for labelling the x-axis
by default. A user who wants to plot everything with frequency labels
may use
alias show "show -freq 0 0"
to create an alias for the show command to use frequency by default.
(use unalias
) to undo this)
In the following we give two examples using the UNIX csh
shell.
The reader is refered to the UNIX system documentation on shell
scripts in order to fully understand the possibilities and limitations
of shell script programming. (The section on the individual commands
contains more examples, e.g. commands
inquire
and
list
.)
Example 1:
The following script (called x
) is distributed with the UNIX
implementation of #
are comments.)
#!/bin/csh -f
# execute a given command (first runstring argument) on one
# or several drp scans (all further runstring arguments)
#
# e.g. 'x int HH57IRS.*'
# where 'int' is a another shell script containing
#
# #!/bin/csh -f
# get -file $1 # access by name
# accum
#
set command=$1 # first argument holds command
shift # now, file names are in $1 ... $n
foreach scan ($*)
echo "$command $scan" # produce some diagnostic output
$command $scan # do it
end
Example 2:
In case you want to loop through scan by number rather than by name you can use the shell's ability to do arithmetic:
#!/bin/csh -f
# execute a given command (first runstring argument) on one
# or several drp scans given by number in the form
# from to increment
#
# e.g. 'do sho HH57IRS.*'
# where 'sho' is a another shell script containing
#
# #!/bin/csh -f
# get $1 # access by number
# show -temp -1 10 # show with fixed temperature scale
#
set command=$1 # first argument holds command
set from = $2
set to = $3
set inc = $4
set scan = $from
while ($scan <= $to)
echo "$command $scan" # produce some diagnostic output
$command $scan # do it
@ scan = $scan + $inc
end
Next Chapter, Previous Chapter
Table of contents of this chapter, General table of contents
Top of the document, Beginning of this Chapter