16.12.2012 Views

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

trap<br />

Usage Note<br />

Examples<br />

Localization<br />

Exit Values<br />

Messages<br />

Portability<br />

command list again and runs the commands. A missing argument or an argument of<br />

− (dash) resets the default trap condition. A null argument ('') causes the trap<br />

condition to be ignored.<br />

If there are no arguments at all, trap prints a list of all the traps and their<br />

commands.<br />

trap is a special built-in shell command.<br />

1. On error or exit, this example deletes a temporary file created during command<br />

execution.<br />

trap ’rm –f /tmp/xyz$$; exit’ ERR EXIT<br />

When an interrupt signal is received, the example prompts whether to abort,<br />

and exits if the answer is y.<br />

trap ’read REPLY?"ABORT??"<br />

case $REPLY in<br />

y) exit 1;;<br />

esac’ 2<br />

2. This example saves your shell history file (specified by the value you give the<br />

HISTFILE environment variable) before timing you out, so you can restore it<br />

when you log on again.<br />

trap ’cp $HISTFILE $HOME/old_hist.bak; exit’ ALRM<br />

trap uses the following localization environment variables:<br />

v LANG<br />

v LC_ALL<br />

v LC_MESSAGES<br />

v NLSPATH<br />

See Appendix F for more information.<br />

0 Successful completion<br />

1 Failure due to any of the following:<br />

v Incorrect signal name<br />

v Incorrect signal number<br />

2 Incorrect command-line argument<br />

Possible error messages include:<br />

name not a valid trap name<br />

You specified an unrecognized trap name. The usual cause of this error is a<br />

typing mistake on the command line.<br />

P<strong>OS</strong>IX.2, X/Open Portability Guide.<br />

708 z/<strong>OS</strong> <strong>V1R9.0</strong> <strong>UNIX</strong> <strong>System</strong> <strong>Services</strong> <strong>Command</strong> Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!