![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Return codes of RDIST | vishal_ranjan | HP-UX | 0 | 06-06-2007 02:01 AM |
| Return Codes | kris01752 | UNIX for Advanced & Expert Users | 3 | 09-25-2006 09:40 AM |
| Return codes | Bab00shka | UNIX for Dummies Questions & Answers | 4 | 02-02-2006 09:46 AM |
| Help with Return codes | leezer1204 | UNIX for Dummies Questions & Answers | 1 | 04-26-2005 09:10 AM |
| return codes from rsh commands... | bbouch | UNIX for Dummies Questions & Answers | 1 | 02-20-2002 03:03 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
|||
|
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 |
|
|||
|
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 |
|||
| Google UNIX.COM |