473,378 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Checking return/exit codes ...

39
Hallo everyone,

I have a perl script which can return error codes. I have done this with, for example, 'exit 11;', which would (I imagine) send the exit code 11 (instead of 0) back to the calling program.

I would now like to check that my error codes are being returned correctly and so wanted to write a short script to test this. Here I considered using the following ...

$checkexitcode = system ("perl myscript.pl");

but believe that this will simply catch the return/exit code from 'system' or from 'perl' and not the return code from 'myscript.pl'.

Can anyone help me with this? Maybe you already have a simple script to test for return codes?

Many thanks,
Alan Searle.
Jan 31 '07 #1
3 55623
miller
1,089 Expert 1GB
According to the documentation for both of those functions that should work:

http://perldoc.perl.org/functions/exit.html
http://perldoc.perl.org/functions/system.html

I've never had any personal experience with that particular need, so you'll have to test to make sure (which is the whole point I know). But system is the correct command to use as far as I know, as exec does not return a value.
Jan 31 '07 #2
KevinADC
4,059 Expert 2GB
see die() instead of exit();
Jan 31 '07 #3
shantu
1
see die() instead of exit();
As miller specified your answer is in the following link,

http://perldoc.perl.org/functions/system.html

$checkexitcode = system ("perl myscript.pl");

You were right. In the above command $checkexitcode is the return code from the system and not the exit code of myscript.pl

To get the return code of myscript.pl you should shift system exit code to right by 8. I mean "$checkexitcode >> 8" will give you the exit code from the myscript.pl.

Also "$?" is same as $checkexitcode. So you can also use "$?>>8" to get the exit code of script that you are executing
May 22 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: - ions | last post by:
I have created a JComboBox with its Items as a list of "M" numbers ie. M1,M2,M3.......throgh too M110 (thes are the messier objects, a catolouge of deep sky objects) the user selects of of these...
2
by: George Sakkis | last post by:
I downloaded the latest Komodo (3.1) and configured it for python 2.4 so that it doesn't show decorators and genexps as syntax errors, but background syntax checking doesn't seem to work at all for...
6
by: RoSsIaCrIiLoIA | last post by:
Do you know how to write a self-checking program in standard C? Do I can think that if I write in a file.c static g="1234567"; in the file.exe (or file) there is in some place...
16
by: Fao, Sean | last post by:
As far as I can tell, the standard has defined three portable return codes from function main() (0, EXIT_SUCCESS, EXIT_FAILURE). Personally, on all platforms I have worked with, EXIT_SUCCESS is,...
10
by: Tony | last post by:
I am running an application called AcroComm.exe to poll time clocks here at our company. I have written a small C# app that will poll the clocks based on information found in a DB. My problem is...
5
by: # include | last post by:
what is the ((((return any no;))) in the main mean plz Ex. int main() { ; ; ; return ??;
11
by: =?Utf-8?B?Um9nZXIgVHJhbmNoZXo=?= | last post by:
Hello, I have a question about the infamous GOTO statement and the way to return a result from a sub: I have a sub that has to make some calls to external COM methods, and because these...
10
by: =?iso-8859-1?q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
Over on comp.lang.c++, we were dicussing the replacment of: if (expr) Func(); with: expr && Func(); My own initial reaction was that, if I saw the latter in code, I'd say the programmer...
46
by: Bill Cunningham | last post by:
I have heard that return -1 is not portable. So what would be the answer to portability in this case? What about exit(0) and exit (-1) or exit (1)? Or would it be best to stick with C's macros,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.