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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to redirect stderr from top with csh umen Shell Programming and Scripting 2 02-23-2007 01:19 AM
csh stderr redirection jolok Shell Programming and Scripting 0 04-15-2005 11:03 AM
'tee' STDERR output (ksh) gsatch Shell Programming and Scripting 5 08-21-2002 01:19 PM
stderr redirection in csh script thehoghunter Shell Programming and Scripting 0 01-28-2002 10:15 AM
stderr dell9 High Level Programming 1 11-21-2001 06:49 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 12-12-2002
blakmk blakmk is offline
Registered User
  
 

Join Date: Oct 2002
Location: London
Posts: 13
stderr redirection

Does anyone know away of redirecting the stderr for a bourne or korn shell script to a file.
  #2 (permalink)  
Old 12-12-2002
Ralf's Avatar
Ralf Ralf is offline
Registered User
  
 

Join Date: Oct 2002
Posts: 34
I though it was the same for all shells?

This shold produce a file 'junk.txt' with an error from stderr

Code:
$ RunFail > junk.txt 2>$1
  #3 (permalink)  
Old 12-12-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,119
Actually it's:
$ RunFail > junk.txt 2>&1

That is you need an ampersand, not a dollar sign. And that syntax will not work with csh or csh clones.
  #4 (permalink)  
Old 12-12-2002
blakmk blakmk is offline
Registered User
  
 

Join Date: Oct 2002
Location: London
Posts: 13
Thanks Perderabo.

I I rewrite it as:
RunFail >> junk.txt 2>>&1

will it append to the file?
  #5 (permalink)  
Old 12-12-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,119
There is no such thing as 2>>&1

>> junk.txt
will open the file in append mode and attach it to fd 1

2>&1
will duplicate fd 1 and attach it to fd 2. You use this form for everything. It does not matter how fd 1 came to exist.
  #6 (permalink)  
Old 12-12-2002
Ralf's Avatar
Ralf Ralf is offline
Registered User
  
 

Join Date: Oct 2002
Posts: 34
Opps to my typo

thanks Perderabo
Closed Thread

Bookmarks

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 12:31 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