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
error redirection sais UNIX for Dummies Questions & Answers 7 05-15-2008 03:28 AM
awk two file redirection kamel.seg Shell Programming and Scripting 1 12-18-2007 02:17 PM
Redirection or piping error message mariner Shell Programming and Scripting 2 05-10-2005 03:04 PM
.forward file for mail redirection giannicello UNIX for Dummies Questions & Answers 3 01-12-2002 11:06 AM
File redirection namtab UNIX for Dummies Questions & Answers 4 01-10-2002 11:48 AM

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-23-2008
maxmave maxmave is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 21
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
  #2 (permalink)  
Old 04-23-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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?
  #3 (permalink)  
Old 04-23-2008
maxmave maxmave is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 21
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
  #4 (permalink)  
Old 04-23-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
That's precisely what the exec does. I still don't understand the exit status check part.
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 07:00 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