next up previous 405
Next: Breaking-in
Up: C-shell Cookbook
Previous: UNIX-style options


Debugging scripts

Earlier a number of ways to run a script were presented. There is yet another, which makes debugging easier. If you invoke the script with the csh command you can specify none or one or more options. The command takes the form

     % csh [options] script
where script is the file. There is a choice of two debugging options.

     % csh -x myscript
     % csh -v myscript
The x option echoes the command lines after variable substitution, and the v option echoes the command lines before variable substitution. The v is normally used to identify the line at which the script is failing, and the x option helps to locate errors in variable substitution. As these options can produce lots of output flashing past your eyes, it is often sensible to redirect the output to a file to be examined at a comfortable pace.

If you prefer, you can run the script in the normal way by putting the option into the first comment line.

     #!/bin/csh -x


next up previous 405
Next: Breaking-in
Up: C-shell Cookbook
Previous: UNIX-style options

C-shell Cookbook
Starlink Cookbook 4
Malcolm J. Currie
2006 November 26
E-mail:starlink@jiscmail.ac.uk

Copyright © 2014 Science and Technology Facilities Council