[clug] shell stdout and stderr
Tony and Robyn Lewis
beakysnugger at yahoo.co.uk
Thu Dec 1 03:52:17 GMT 2005
In a bourne shell, I want to make all stderr (and stdout) go to files,
*from within that script* - i.e. the standard redirection won't cut it.
For example, if something like "File does not exist" is written to
stdout in my script, because it tries to run some non-existent command,
I want that to go to a file that I nominate, *from within the script*
pseudoscript:
#!/bin/sh
redirect_my_std_err /tmp/mystderr
/run/this/missing/command
exit 0
I want the error of "sh: /run/this/missing/command: No such file or
directory" to end up in /tmp/mystderr
Any clues?
If you're curious why, it's because I've got a gazillion scripts that
I'm tidying up, and I want to generalise the stdout and stderr of these
things to go to a file that I can then mail to someone and/or append to
some larger log file - a logging wrapper script.
It's all working well for capturing stdout and stderr of the target
script (simple redirection), but not if something generates an error
within the log wrapper, such as being unable to find / execute the
target script/
Clear? Good.
Pointers appreciated.
Tony
More information about the linux
mailing list