Usage and examples of Sequencer scripts
The basic way of using the sequencer is by typing sequencer commands in a
terminal window.
The sequencer commands are exactely like any other UNIX command in the
way that they
are executed and exists as processes. As they get executed by the shell
(C shell by default), all aspects of job control, shell syntax etc. applies
to the sequencer commands as they do to any other UNIX command.
They can be put in the background, using "Ctrl-Z, bg" or using "&" after the
command. An example of this is the "expose" command. If given normally, i.e.
executing in the foreground, the command will not return until the image is
read out and stored on disk. You can execute the command in the background
("expose &") and get the command prompt back immediately. In this case you
can use the "about" command to about the on-going exposure.
These comments are only highlights of a small number of possibilities available.
The real "sequencer manual" is, in fact, a manual of the UNIX C shell (or the
shell of your choice if using a script).
There is great flexibility when writing scripts for the sequencer. As the
normal UNIX tcsh shell is used, the syntax is well documented elsewhere
Click here for a manual in C shell script writing
It is also possible to use BASH for making scripts, in any case the full command
names must be used (e.g. alfosc.xbin). The full command names for the
different command groups can be found in the command reference in the
header for the command groups (i.e. BIAS, instrument, TCS, etc.)
You may copy any instrument script to your own directory for editing, for instance doing:
cp ~staff/alfosc.polspecwin my.polspecwin
There are some basic rules that must be followed to get the correct behaviour.
- The first line of the script MUST be
#!/bin/tcsh
or
#!/bin/bash
in the case you want to use BASH.
- Before you can use your script, you have to make it executable with the
command
chmod +x my_script
- Commands (in this case sequencer commands) can be executed in the
background putting a '&' after the command. In this case,
the script will immediately continue to the next command in the script.
- The script can use parameters given on the command line. These are
accessible in the variables $1, $2 etc.
In the script executed like this:
my_script var1 var2
var1 will be available as $1 and var2 as
$2.
- Your script can (and should if it is complicated) log informative
messages to the talker (and thus to the user), using the logger
command.
Three levels of logging can be used - DEBUG, NOTE and ERROR. DEBUG is
used for functionality debugging and can only be seen when this level
has been enabled in the Talker. NOTE is the normal way of logging
informative messages. ERROR is only used for errors produced by the
programme/script. The ERROR messages will appear in red in the Talker.
Here is how to use it:
/usr/bin/logger -p local0.debug -t "scriptname" "[NOTE]: My note"
for normal log messages
/usr/bin/logger -p local0.debug -t "scriptname" "[DEBUG]: My note"
for debug log messages
/usr/bin/logger -p local0.debug -t "scriptname" "[ERROR]: My note"
for error log messages
, where "scriptname" must be an informative name of your script.
Alternatively, '$0' can be used as scriptname to use the current filename.
The square brackets, the colon and the following space must be there.
We strongly advice to notify the talker upon start and end of script execution:
logger -p local0.debug -t "$0" "[NOTE]: Script started as $0 $*"
... the script ...
logger -p local0.debug -t "$0" "[NOTE]: Script ended successfully"
The '$0' will echo the script name, and '$*' will echo the parameters which the
script was called with.
An example:
An ALFOSC script that will make a 300 second exposure with a teloffset of variable size
(to be given on the command line) in 3 filters can be written like this:
#!/bin/tcsh
logger -p local0.debug -t "$0" "[NOTE]: Script started as $0 $*"
set xoffset = $1
set yoffset = $2
set filters = "1 2 3"
foreach filter ($filters)
alfoscinst.filter $filter
alfosc.expose 300
tcs.teloffset $xoffset $yoffset
end
logger -p local0.debug -t "$0" "[NOTE]: Script ended successfully"
exit
This script will then be used like
myscript 10.0 10.0
The commands that moves an element (a filter, grism, arm etc.etc) will
not complete until this movement has been made. This means that in the
script above, the 'expose' command will not start until the filter has
arrived at the commanded position and the 'teloffset' command will not
start until the exposure (and readout) has finished.
|