Rtshell Script Writers Bible
Warning - Script writing and script use should be considered an
exercise left to experienced users, those who are familiar with the
normal operations of the telescopes and instruments. Please feel free to
ask Ted about the workability of specific scripts. Also note comment
below about difficulty in terminating scripts.
Rtshell
was created by Ted Groner to address
several limitations of the long-gone cominterp program.
One major limitation was the lack of scripting. Rtshell
implements scripting.
Scripts allow files to be sourced to control the following classes
of functions:
- 1) Instrument Control
- 2) Telescope Movements
- 3) Unix Commands
How to run scripts
Scripts MUST only be sourced, not run as shell scripts! Since
the rtshell maps in shared memory with the other programs which comprise
the Realtime System, invoking a sub-shell of rtshell is an error. Rtshell
should only be started with the rest of the system. Other scripts run
by rtshell won't know about telescope or other built in commands!
The correct way to run a script, for example a script named my.script,
is "source my.script" Adding arguments to invocation will be discussed
below.
Writing Scripts
Use your favorite editor (emacs, vi, mg, etc) to create a file.
The observer area has a subdir named scripts, designed to hold
rtshell script files. This would be a good place to store your script.
So, if using vi, the command for observer would be "vi ~/scripts/my.script".
Insert your script commands int his file, save the file. In the rtshell
window type "source ~/scripts/my.script". This should run the script.
Script Commands
Unix commands can be split into two group when using any shell. These
commands are considered either "built in" or "system". With built in
commands, the commands are part of the shell itself. With system
commands, the shell executes the command in another process.
All instrument control and telescope movement commands are built into
the rtshell. Some other commands were already built into tcsh, like
"pwd". This document will only attempt to cover the commands that
were added as built ins to the tcsh shell.
Please consult man pages for tcsh(1) and csh(1) for more information
about built in commands. Tcsh is a superset of csh, rtshell is a
superset of tcsh. All other "system" commands are beyond the scope
of this document as well.
Instrument Control Commands
This set of commands control the state of the detector. Which commands
you wish to use depends on what instrument is mounted. Possible
choices include 4shooter, echelle, fast and stelircam. Please consult the
documentation for the instrument of interest. Of special interest
to this discussion are the commands "total, go, bias, flat, dark,
and comp". These commands all instruct the instrument to expose
for a period of time. They were designed to work from the rtshell
window, and to return control of the window back to the observer
after starting the exposure. This is NOT what is needed in a script.
For this reason a special instrument command was created only for
use in script files. This command is "gowait"
The gowait command is fully implemented for onlt the fast and ccd
programs. It should soon be in use for echelle and sonic. I will
use the ccd as an example.
The gowait command for the ccd (and fast) takes the form of:
- ccd gowait [exptime|repcount] [file type[suffix]] where
- exptime stands for length of exposure
- repcount stands for number of exposures (only for BIAS)
- file type stands for the type of exposure(BIAS, FLAT, DARK, COMP)
- suffix stands for a one letter suffix on file name(only FLAT)
The complete list of possible commands becomes
- ccd gowait 30 -- simply expose for 30 seconds, no file type
- ccd gowait 20 FLAT -- take a 20 second flat , named seqnum.FLAT
- ccd gowait 20 FLATV -- take a 20 second flat , named seqnum.FLATV
- ccd gowait BIAS -- take a 0 second bias , named seqnum.BIAS
- ccd gowait 10 COMP -- take a 10 second comp , named seqnum.COMP (FAST)
- ccd gowait 10 DARK -- take a 10 second dark , named seqnum.DARK (not yet)
BEWARE OF "ccd gowait" with NO arguments! This starts an
infinite exposure, which never returns!
Telescope Control Commands
The telescope control commands all have the common prefix "tele". Not
all commands work on all telescopes, as the hardware differs. First we'll
list commands good on both the 60" and 48".
Common Commands
tele coords -- valid commands are:
- "tele coords newcat rudy" - load catalog /Realtime/lib/catalogs/rudy.mct
- "tele coords {1 - load object coords of first line in loaded cat
- "tele coords }TWQSO - load object TWQSO coords from loaded cat
tele enable
This command takes no arguments, and will cause the telescope to
slew to the next loaded coordinates. If you don't use this one, telescope
WILL NOT MOVE.
48" ONLY Commands
- tele offset 120 -30
- (offset telescope in arc seconds; no "tele enable" command is needed following tele offset commands)
- tele filter 3
- (move to third loaded filter)
- tele focus -100
- (move secondary focus)
- tele gfoc -100
- (move guider focus relative to current)
60" ONLY Commands
- tele comp [IN|OUT] - Move FAST comparison mirror IN/OUT
- tele lamp [HEAR|NEON|INCAND] [on|off] -- toggle FAST lamps
- tele ffoc value - Move FAST spectrograph focus
OTHER COMMANDS
- setcom inst keyword val - Set keyword to val for named instrument
Putting it all Together
Most people learn best from example, so here are several!
KILLING A SCRIPT
It is not easy to kill a script, for the shell is occupied during the script and will not accept commands like "kill". Typing
CNTRL-C during readout will sometimes kill each exposure individually, and thus is useful if there are only a few
exposures left. Otherwise, you must kill the rtshell window (using a mouse button to bring up "Destroy
Window"), and then restart the Realtime system. This problem may be avoided by putting in 5 second delays between
each sequenced exposure in the script used, during which time one can type a CNTRL-C which will kill the sequence.
The standard star and dome flat scripts above have such a feature. You may wish
to copy this feature in your scripts.
Back to General Software home page.
Written by Ted Groner Modified
last on 05/21/2001 TG