spec

Software for Diffraction

2.3.11. - Starting Up



When you run spec, you invoke it using a name such as fourc, twoc, surf, spec, etc. That name determines the kind of geometry code that will be available and which macro and configuration files in the auxiliary file directory will be used, as explained below.

The following command line options are recognized by spec:
-C file
Open the command file file as a start-up command file to be read after the standard start-up command files, but before the optional file spec.mac in the current directory, which will always be read last. If there is an error in reading or executing the commands in these files, spec will jump to the main prompt and not read any remaining queued command files. Up to 32 files may be specified with multiple -C options.
-d debug
Sets the initial value of the debugging variable DEBUG to debug, which maybe either in decimal or hexadecimal (with a leading 0x) format. The available debugging categories are described 2.3.15.1
-D direc
Use direc as the auxiliary file directory, instead of the compiled-in name (usually /usr/local/lib/spec.d) or the value of the SPECD environment variable.
-f
Fresh start. All symbols are set to their default values and the standard macros are read to establish the default state. Command-line history is reset unless the -h flag is also present.
-F
Clean and fresh start. All symbols are set to their default values but no command files are read and no macros are defined. Only the built-in commands are available.
-g geometry
Force loading of macro files and activation of geometry calculations for the specified geometry, while using the configuration files taken from the name by which spec is invoked.
-h
Retain history. When starting fresh, reset symbols and macros but keep command-line history. (Added in spec release 6.05.01.)
-l outputfile
Specify an output file. Output to the file will begin immediately, so will include the initial hardware configuration messages. Files will be opened even when starting fresh. Files opened this way will not be saved as output files in the state file, so will not be automatically reopened the next time spec starts (as of spec release 6.04.05).
-L
Do not check or create the state-file lock. Normally, spec prevents more than one instance of itself from running with the same state file (derived from the user name plus tty name). With some system configurations, if the state file resides on an NFS-mounted disk, the file locking doesn't work well and spec will not start. This flag overrides the lock test.
-N my_name
Use my_name instead of the name by which spec was invoked to establish the command prompt and the name of the directory in SPECD in which the configuration-dependent files exisit. This command also sets the geometry to my_name. Follow this option with the -g option to choose a different name for the geometry.
-o option=value
Initializes the spec_par() option to value. The available spec_par() options are described .Mp "on page " #ref_02 "."
-p fd pid
Indicates that spec input is coming from a pipe from another program. The argument fd is the file descriptor that spec should use for standard input. The argument pid is the process ID of the spawning process. If fd is zero, spec will not re-echo input from the file descriptor to spec's standard output.
-q
Indicates that spec should operate in quiet mode and allow output to all devices to be turned off. This option is only valid when used with the -p option.
-s
Simulation mode. No hardware commands are issued. Simulation mode cannot be turned off after entering the program.
-S
Start spec in server mode listening at the first available port in the default range of 6510 to 6530.
-S p1
Start spec in server mode listening at the specified port number p1.
-S p1-p2
Start spec in server mode listening on the first available port in the given range.
-t tty
Use the current user (or user's) last saved state from the terminal specified by tty as the initial state. The terminal can be specified as -t /dev/tty01 or -t tty01. Pseudo-tty names, such as /dev/ttyp0, /dev/ttyp1, etc., are saved as /dev/ttyp#, since there is no special significance to the number.
-T fake_tty
This option creates a user state associated with fake_tty, which may be any name. This option allows you to bypass the locking feature that prevents multiple instances of spec to be started by the same user from the same terminal.
-u user
Use user's last saved state as the current user's initial state.
-v
Print version information and exit.
-y
Yes, change motor controller registers initially if they disagree with the settings file. Normally, spec requires you to confirm such a change. This flag would be useful if you know controller power had been turned off, and the controller's current positions should be updated with the software positions.


In some installations, spec is installed as a set-user-id root process, to allow certain calls that allow privileged access to hardware device registers. The first thing spec does on start up is to set the effective user and group ids to that of the real user, so there is no danger of the user spawning subshells or creating files as root. The root effective id is only used for the duration of the calls that enable the privileged access.

spec then performs other initialization tasks, including obtaining values for its internal variables DISPLAY, GTERM, TERM and HOME from variables of the same name in the process environment. It also obtains the value of the SHELL environment variable for use with the unix() function.

spec then reads the hardware configuration from the appropriate config file from the auxiliary file directory. The path name of that file is SPECD/spec/config, where SPECD is the auxiliary file directory, established when spec is installed (or by the -D invocation flag, or by the SPECD environment variable), and spec is the name by which spec is invoked.

The first time a user starts spec, up to seven macro files are automatically read. The path names of these files are
SPECD/standard.mac
SPECD/geom.mac
SPECD/spec/geom.mac
SPECD/site_f.mac
SPECD/site.mac
SPECD/spec/conf.mac
./spec.mac
where SPECD is the auxiliary file directory, as described above, geom matches the first four letters of the name by which spec was invoked and spec is the complete name by which spec was invoked. The files are only read if they exist. The files SPECD/standard.mac, SPECD/geom.mac, SPECD/spec/geom.mac and SPECD/site_f.mac are only read if the user is starting spec for the first time or has invoked spec with the -f (fresh start) flag.

Each time spec starts up, if a macro named begin_mac is defined, that macro will be run after reading any startup command files, but before input is read from the keyboard.

After reading the start-up macro or command files and possibly running begin_mac, spec prompts the user for commands.