Operating System - HP-UX
1828009 Members
2338 Online
109973 Solutions
New Discussion

Re: Redirect stderr to display and file

 
SOLVED
Go to solution
Yaash
Occasional Advisor

Redirect stderr to display and file

Hello,

Need assistance to redirect stderr to a file and display simutaneously.

Thanks.
3 REPLIES 3
Ivan Krastev
Honored Contributor
Solution

Re: Redirect stderr to display and file

Take a look at this script - http://www.travishartwell.net/blog/2006/08/19_2220

regards,
ivan
Dennis Handly
Acclaimed Contributor

Re: Redirect stderr to display and file

It would be easier to redirect stderr to a file then if you desire, use more on that file:
$ command 2> file &
$ more file

Otherwise you would have to use tee(1) and that would have issues with what you want to do with stdout.
James R. Ferguson
Acclaimed Contributor

Re: Redirect stderr to display and file

Hi:

If you wish to only have STDERR recorded in a file, but *both* STDERR and STDOUT written to your terminal simultaneously, you could do:

# ./myprocess 2>&1 1>/dev/tty|tee ./mylog

...where, for example:

# cat ./myprocess
#!/usr/bin/sh
while true
do
print -u2 "STDERR"
echo "STDOUT"
sleep 1
done

Regards!

...JRF...