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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Return codes of RDIST vishal_ranjan HP-UX 0 06-06-2007 06:01 AM
Return Codes kris01752 UNIX for Advanced & Expert Users 3 09-25-2006 01:40 PM
Return codes Bab00shka UNIX for Dummies Questions & Answers 4 02-02-2006 01:46 PM
Help with Return codes leezer1204 UNIX for Dummies Questions & Answers 1 04-26-2005 01:10 PM
return codes from rsh commands... bbouch UNIX for Dummies Questions & Answers 1 02-20-2002 07:03 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 02-04-2008
ammu ammu is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 79
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
  #2 (permalink)  
Old 02-04-2008
grumpf grumpf is offline
Registered User
  
 

Join Date: May 2006
Posts: 101
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
  #3 (permalink)  
Old 02-04-2008
ammu ammu is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 79
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
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 10:18 PM.


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