The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
error redirection sais UNIX for Dummies Questions & Answers 7 05-15-2008 12:28 AM
awk two file redirection kamel.seg Shell Programming and Scripting 1 12-18-2007 10:17 AM
Redirection or piping error message mariner Shell Programming and Scripting 2 05-10-2005 12:04 PM
.forward file for mail redirection giannicello UNIX for Dummies Questions & Answers 3 01-12-2002 07:06 AM
File redirection namtab UNIX for Dummies Questions & Answers 4 01-10-2002 07:48 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-23-2008
Registered User
 

Join Date: Apr 2008
Posts: 20
Stumble this Post!
Error file Redirection

Hello All,

I was wondering is there any other way in Shell Scripting to redirect the errors to a output file inside a shell script with using a error status checking or a command line redirection.

Say without doing this

ksh test.ksh 2> error.txt

or without doing this ...

if [ "$?" = "1" ]; then
exit 1
fi

Thanks

Rahul
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-23-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Stumble this Post!
Your question is not very clear, but my hunch is you might be looking for this.

Code:
exec 2>error.txt
I don't understand the status checking part, though. Is that a different question?
Reply With Quote
  #3 (permalink)  
Old 04-23-2008
Registered User
 

Join Date: Apr 2008
Posts: 20
Stumble this Post!
My Question is If we need to redirect the error output to a text file in shell script

we can do by using this ksh test.ksh 2> errorfile.txt
or We can do a Exit Status check as below ..

if [ "$?" = "1" ]; then
...
fi


But What my doubt is there any other way to redirect the the errors to the error file rather than using the command line redirection to a text file. I want to handling the error redirecting part within the shell script.

Thanks in advance

Rahul
Reply With Quote
  #4 (permalink)  
Old 04-23-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Stumble this Post!
That's precisely what the exec does. I still don't understand the exit status check part.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0