How to use tee with stdout and stderr?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to use tee with stdout and stderr?
# 1  
Old 11-16-2005
How to use tee with stdout and stderr?

I have been doing this:

make xyz &> xyz.log &; tail -f xyz.log

The problem with this is that you never can ge sure when "make xyz" is done.

How can I pipe both stderr and stdout into tee so both stderr and stdout are copied both to the display and to the log file?

Thanks,
Siegfried
# 2  
Old 11-18-2005
make xyz 2>&1 | tee xyz.log
This User Gave Thanks to Ygor For This Post:
# 3  
Old 01-14-2009
for showing and redirecting at the same time, you can use:

./program 2>&1 | tee program.log

in the file program.log, the statement stores stdout and stderr as well.
# 4  
Old 01-14-2009
There's no need to provide the same answer three years after the question was asked.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help required with Stderr and tee command

Hello All, I have a requirement to redirect stdout and stderr to 'log' file and stderr alone to 'err' file. Can someone please help me with this? Thanks in advance (2 Replies)
Discussion started by: vikas_trl
2 Replies

2. Shell Programming and Scripting

Automatically send stdout and stderror to a file as well as to the screen, but without using tee

Hi, I've been using the following commands in my automated scripts, to ensure that all text output is sent to a log file instead of to the screen: exec 1>>$SCRIPT_LOG_FILE exec 2>>$SCRIPT_LOG_FILE However, I've now discovered that the system used for automating the script executions... (4 Replies)
Discussion started by: confusedAdmin
4 Replies

3. Shell Programming and Scripting

stdout, stderr redirection

Hi all, can someone help me with the next redirection? i want to redirect the stdout+stderr of a command to the same file (this i can do by prog &> file) but in addition i want to redirect only the stderr to a different file. how can i do this please? (in BASH) thanks. (4 Replies)
Discussion started by: eee
4 Replies

4. Shell Programming and Scripting

stderr/stdout

Can somebody explain to me why the diff output is not going to stderr? Yet when I issue a diff from the command line the return code is -ne 1. I am guessing diff always writes to stdout??? Is there away I can force the difff to write to stderr USING THE CURRENT template. If possible, I... (5 Replies)
Discussion started by: BeefStu
5 Replies

5. Red Hat

Make STDERR readable as STDOUT

Hi all. I am trying to use backticks in Perl to put STDERR into a string. The code is... $readkey_test = `perl -MTerm::ReadKey -e 1`; print $readkey_test; if ($readkey_test =~ m/]/) { print "ReadKey not installed...\n"; } else { print "ReadKey installed...\n"; } If it comes up... (3 Replies)
Discussion started by: austinharris43
3 Replies

6. Shell Programming and Scripting

Is there a way to tee stderr from a command that's redirecting error to a file?

I'm not a complete novice at unix but I'm not all that advanced either. I'm hoping that someone with a little more knowledge than myself has the answer I'm looking for. I'm writing a wrapper script that will be passed user commands from the cron... Ex: ./mywrapper.sh "/usr/bin/ps -ef |... (1 Reply)
Discussion started by: sumgi
1 Replies

7. Shell Programming and Scripting

STDERR to file & terminal using tee

Hi All, Solarix/Bash v3x Im trying to output any standard errors created by the script to a file using the below command: . runDTE.sh 2> "$DTE_ERROR_FILE" however the errors do get written to the dir/file stored in $DTE_ERROR_FILE but the error does not appear on the terminal screen in... (4 Replies)
Discussion started by: satnamx
4 Replies

8. UNIX for Advanced & Expert Users

combined stdout & stderr

Hello Everyone! I'm trying to combine output for standard output and for possible standard error to the log file. I was trying to use tee command, but it turned out if error occurred error output will be send to the screen only and will not be redirected with tee command to the log file. Anyone... (11 Replies)
Discussion started by: slavam
11 Replies

9. Shell Programming and Scripting

precedence of stderr and stdout

#!/usr/bin/perl open(STDOUT, ">>$Textfile") open(STDERR, ">>$Textfile") print "program running\n"; $final = join("+", $initial,$final) #5 close (STDOUT); close (STDERR);Hi all, above is my perl code. Notice i have captured the stdout and stderr to the same textfile. my code is expected to... (1 Reply)
Discussion started by: new2ss
1 Replies

10. Shell Programming and Scripting

Redirect stdout and stderr

How can I redirect and append stdout and stderr to a file when using cron? Here is my crontab file: */5 * * * * /dir/php /dir/process_fns.php >>& /dir/dump.txt Cron gives me an 'unexpected character found in line' when trying to add my crontab file. Regards, Zach Curtis POPULUS (8 Replies)
Discussion started by: zcurtis
8 Replies
Login or Register to Ask a Question