Writing Shell Scripts

As Miriad commands can be invoked directly from the command line, scripts and command procedures to run a sequence of Miriad commands can be developed using the normal host's facilities. This is a somewhat advanced topic - you will probably want to be familiar with the shell scripts and Miriad before you attempt to develop your own script.

There are numerous books written of shell programming or the like - a manual like this cannot be expected to cover the subject in the depth that these books go into. Instead a simple annotated example will be given using the C-Shell commonly used on UNIX systems. To aid description, line numbers are given on the left side of each line (these line numbers are not part of the shell script).

  1:  #!/bin/csh
  3:  # Delete any datasets called "multi.uv".
  5:  rm -rf multi.uv
  7:  fits in=MULTI.UV op=uvin out=multi.uv
  9:  foreach srcnam ( 1934-638 0823-500 vela )
 10:    uvaver vis=multi.uv "select=source(${srcnam})" out=${srcnam}.uv
 11:  end
 13:  mfcal vis=1934-638.uv interval=10 refant=3
 14:  gpcal vis=1934-638.uv interval=10 options=xyvary refant=3
 15:  gpcopy vis=1934-638.uv out=0823-500.uv
 17:  gpcal vis=0823-500.uv interval=10 \
 18:                 options=nopol,xyvary,qusolve refant=3
 20:  gpboot vis=0834-500.uv cal=1934-638.uv
 21:  uvplt vis=0823-500 stokes=i,q,u,v axis=real,imag device=0823.ps/ps
 23:  lpr 0823.ps

On UNIX systems, after having developed a script, you will need to change the ``file mode'' of the script to indicate that the script is executable. For example, to mark the shell script calibrate as executable, use the UNIX command

     % chmod +x calibrate

Miriad manager