How can I collect and see error messages?

Maarten Litmaath maart at cs.vu.nl
Sat Jun 10 10:26:57 AEST 1989


stacym at hpldsla.HP.COM writes:
\...
\   For those who don't know, FBACKUP is a backup utility.

Really? I'd have sworn it was an editor! :-)

\   Anyways, occasionally I receive some error messages from the
\   utility.  I would like to be able to see these messages on
\   the console as they come out, but I would also like to
\   be able to collect these messages within a file.  From 
\   what I have been able to tell, I can redirect the error output
\   to a file by use of 2> filename, but then I can not see the 
\   error messages on the screen. [...]

Example:

	$ cat foo
	hello world
	$ log errors cat foo bar
	hello world
	bar: No such file or directory
	$ cat errors
	bar: No such file or directory
	$ log errors 'Pointer Addition'
	$ cat errors
	bar: No such file or directory
	Pointer Addition: Protocol not supported
	$

Script:
----------8<----------8<----------8<----------8<----------8<----------
#!/bin/sh
# @(#)log 1.0 89/06/10 Maarten Litmaath
# log - save error messages in a logfile, duplicate them on stderr

test $# -lt 2 && {
	echo "Usage: `basename $0` <error logfile> <command>" >&2
	exit 1
}

ERRLOG=$1
shift

exec 3>&1
"$@" 2>&1 >&3 | tee -a "$ERRLOG" >&2
----------8<----------8<----------8<----------8<----------8<----------

\...
\   When using DOS, CTRL-ALT-DEL always deletes the current line.

When using SunOS 3.5 "date > /dev/printer" will get you out of the editor.
rot13:
qba'g qb guvf ng ubzr, xvqf...
-- 
 "Your password [should be] like your |Maarten Litmaath @ VU Amsterdam:
      toothbrush." (Don Alvarez)      |maart at cs.vu.nl, mcvax!botter!maart



More information about the Comp.unix.questions mailing list