Using TRAP command

I'm using the trap command to capture any signals received whilst my script is running.

How's the best way of writing the signal and any other error messages to a file/error log' without having to type '2>$1' on the command line after the script name?

Cheers

Hi
depends..

I use the logger command (it logs to syslog). It depends on what kind of error checking your script has..

output everything to a file is the simplest way..

/peter

Thanks for your reply

You could use the special command: "exec" to redirect stdout and stderr, e.g. if you put this at the top of your script ....

exec > /tmp/logfile$$ 2>&1

... all messages will go to the log file.

From man ksh...