Path: utzoo!attcan!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: How can I collect and see error messages? Message-ID: <2723@kappl.cs.vu.nl> Date: 10 Jun 89 00:26:57 GMT References: <9220001@hpldsla.HP.COM> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 56 stacym@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` " >&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@cs.vu.nl, mcvax!botter!maart