4 Command files

Contents of this section

Because DRP works directly from the shell of the underlying operating system, its commands may be combined into more powerful procedures by collecting them in executable `command files'. Depending on the operating system these may be better known as shell scripts (UNIX), batch files (MS-DOS) or REXX scripts (AMIGA). Their syntax and capabilities will of course depend on the operating system (and the particular shell) being used.

Because DRP commands may be cumbersome if used with a lot of options, it is essential that the user picks a shell with comfortable history mechanisms (like the 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 DRP and allows you to carry out the same command (which in turn might be a command script) on a number of scans: (Lines starting with a # 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