The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to use tee with stdout and stderr? siegfried Shell Programming and Scripting 3 01-14-2009 10:07 PM
combined stdout & stderr slavam UNIX for Advanced & Expert Users 11 10-12-2007 03:06 PM
redirecting STDOUT & STDERR jshinaman Shell Programming and Scripting 9 06-22-2007 12:04 AM
stderr & stdout to a file and the right exit code up69 Shell Programming and Scripting 2 08-17-2006 01:40 PM
Redirect stdout & stderr and append to a file Santi Shell Programming and Scripting 2 01-02-2006 07:58 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-09-2008
vikashtulsiyan vikashtulsiyan is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 42
Redirecting STDERR message to STDOUT & file at same time

Friends
I have to redirect STDERR messages both to screen and also capture the same in a file.
2 > &1 | tee file works but it also displays the non error messages to file, while i only need error messages.
Can anyone help??
  #2 (permalink)  
Old 04-09-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
Code:
prog 2 > | tee file
  #3 (permalink)  
Old 04-09-2008
vikashtulsiyan vikashtulsiyan is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 42
it doesn't work
it neither print the ERROR messages on the screen nor on file
  #4 (permalink)  
Old 04-09-2008
V3l0 V3l0 is offline
Registered User
  
 

Join Date: Nov 2007
Location: Belgium & France
Posts: 70
Code:
prog 1>/dev/null | tee fil
Not tested ...
  #5 (permalink)  
Old 04-09-2008
vikashtulsiyan vikashtulsiyan is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 42
no man. The requirement is this.

while running an application I have to print STDERR messages both on screen(STDOUT) and file at the same time while the normal STDOUT messages should be on screen only.
  #6 (permalink)  
Old 04-09-2008
V3l0 V3l0 is offline
Registered User
  
 

Join Date: Nov 2007
Location: Belgium & France
Posts: 70
Use this:
Script is "cmd"
Code:
#!/bin/sh
echo "This is Standard Out"
echo "This is Standard Error" >&2
Use cmd script like this:
Code:
((./cmd 3>&1 1>&2 2>&3) | tee /dev/tty) > err.log
The output is:
Code:
((./cmd 3>&1 1>&2 2>&3) | tee /dev/tty) > err.log
This is Standard Out
This is Standard Error
File err.log contains only stderr:
Code:
cat err.log
This is Standard Error
I think it's good now !
Closed Thread

Bookmarks

Tags
redirect, stderr

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:03 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0