next up previous 405
Next: Executing a Starlink Application
Up: Shell Variables
Previous: Script arguments and other special variables


Predefined variables

The C-shell has some predefined variables. We've already met argv. The most useful other ones are listed below.

Shell variable Meaning
   
cwd Current working directory
home Home directory
path List of directories in which to search for commands
status The status returned by the last command, where 0 means a successful completion, and a positive integer indicates an error, the higher the value, the higher the severity.
user Username
   

So if you wanted to include details of the user and directory at the head of some data-processing log you might write this in your script.

     % echo "Processed by:        $user" > logfile
     % echo "Directory processed: $path" >> logfile
This writes a heading into file logfile saying who ran the script, and then appends details of the directory in which processing occurred. Note the different metacharacters, namely > redirects the output to a file, and » appends to an existing file.



next up previous 405
Next: Executing a Starlink Application
Up: Shell Variables
Previous: Script arguments and other special variables

C-shell Cookbook
Starlink Cookbook 4
Malcolm J. Currie
2006 November 26
E-mail:ussc@star.rl.ac.uk

Copyright © 2009 Science and Technology Facilities Council