help with return codes | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

help with return codes

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-04-2008
ammu ammu is offline
Registered User
 
Join Date: Jul 2006
Last Activity: 26 August 2010, 9:37 AM EDT
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
help with return codes

Hi

In an unix script I am using an Perl one liner perl -i -ne '-----'
If the perl one liner fails i am not able to catch the return code.
It always give 0 as return code. Can you tell me how can i catch the return code

perl -i -ne '---'
RETCODE=$?
echo $RETCODE

Thanks and Regards
Ammu
Sponsored Links
    #2  
Old 02-04-2008
grumpf grumpf is offline
Registered User
 
Join Date: May 2006
Last Activity: 24 October 2008, 11:54 AM EDT
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
works for me:

$ LANG=C ./test.sh
Can't open perl script "print hello": No such file or directory
2 <<= return code != 0


you can check success:

$perl -e 'print "hello\n" ' ; echo $?
hello
0


you can change the return value:
$perl -e 'print "hello\n"; exit 99; ' ; echo $?
hello
99
Sponsored Links
    #3  
Old 02-04-2008
ammu ammu is offline
Registered User
 
Join Date: Jul 2006
Last Activity: 26 August 2010, 9:37 AM EDT
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Actually i am using the following perl onliner (to delete 1 and 2 line from the file)

perl -i -ne 'print unless 1..2' filename

echo $?

If i give a wrong file name too it gives return code it throws error and give return code 0
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Different Return Codes aarti.popi Shell Programming and Scripting 3 05-29-2009 07:53 AM
Displaying Return Codes hern14 UNIX for Dummies Questions & Answers 2 05-01-2008 02:23 PM
Return Codes kris01752 UNIX for Advanced & Expert Users 3 09-25-2006 12:40 PM
Return codes Bab00shka UNIX for Dummies Questions & Answers 4 02-02-2006 12:46 PM
Help with Return codes leezer1204 UNIX for Dummies Questions & Answers 1 04-26-2005 12:10 PM



All times are GMT -4. The time now is 05:10 PM.