selig@udcps3.cps.udayton.edu (Paul D. Selig) (10/20/89)
I have a simple question for all you "shell" wizards out there: I need to have a way that will take a shell script that is written by a student and run that script, while at the same time writing all input (either from the keyboard or a file), output, and error output to a "log" file, while at the same time accepting input from the keyboard and writing the output to the screen. It would need to be invoked as follows: runandlog <scriptname> logfile which would run the script <scriptname> and write the input/output/error output to the file <logfile>. This also needs to to be run under the Bourne shell :-) Any and all help E-mailed to the above address will be appreciated!!! Paul Selig -- | | Paul Selig, Jr. Systems Administrator | --|- Computer Science Department, Anderson Center 133 | | | | The University of Dayton, Dayton, Ohio 45469 --|- | BITNET: selig@dayton.bitnet ---- UUCP: selig@cps.udayton.edu or ...!uunet!ncrlnk!udcps3!selig
maart@cs.vu.nl (Maarten Litmaath) (10/20/89)
selig@udcps3.cps.udayton.edu (Paul D. Selig) writes: \I need to have a way that will take a shell script that is written by a \student and run that script, while at the same time writing all input \(either from the keyboard or a file), output, and error output to a "log" \file, while at the same time accepting input from the keyboard and writing \the output to the screen. [...] /usr/ucb/script would do what you want. If you only want to log error messages, you can use the following script. ----------8<----------8<----------8<----------8<----------8<---------- #!/bin/sh # @(#)log 1.1 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 3>&- | tee -a "$ERRLOG" >&2 ----------8<----------8<----------8<----------8<----------8<---------- -- A symbolic link is a POINTER to a file, | Maarten Litmaath @ VU Amsterdam: a hard link is the file system's GOTO. | maart@cs.vu.nl, mcsun!botter!maart