Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing script output to files and screen via tee

Status
Not open for further replies.

dendenners

Programmer
Jul 17, 2001
110
IE
Hi,
I have scripts whose stdout and stderr output I pipe to 2 different files like so:
script.sh > /tmp/out 2>/tmp/out_err
I would like this output (both stdout and stderr) to also appear on the screen when I run the script. I know I could do
script.sh | tee /tmp/out
but this would pipe all output to only one file. Is it possible to keep error and standard output apart in files and also write all to the screen? Thanks
 
hi,

one simple way would be to create another script which calls

your main script with :-
script.sh > /tmp/out 2>/tmp/out_err

and then cat the files after it if they are not empty.

script.sh > /tmp/out 2>/tmp/out_err
cat /tmp/out
cat /tmp/out_err

one other thought for you is to use exec in your script i.e

testingproc()
{
exec 1>>/tmp/out.std 2>>/tmp/out.err

commands

}

#### main prog

testinproc

( if you know how to undo the exec so it no longer writes
to the files you can add a cat command )

good luck


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top