473,624 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking return/exit codes ...

39 New Member
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 55667
miller
1,089 Recognized Expert Top Contributor
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 Recognized Expert Specialist
see die() instead of exit();
Jan 31 '07 #3
shantu
1 New Member
see die() instead of exit();
As miller specified your answer is in the following link,

http://perldoc.perl.or g/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 "$checkexit code >> 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
7574
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 and views it aswell as infomation. The program also has a JTextFiels which allows the user to enter the M number. The problem i have is checking that what the user has entered is valid, that being an M followed by 1 - 110 Nothing else, i thought of...
2
2049
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 python 2.4. Even for correct files, it shows a "Syntax checking error: Error checking syntax: retval = 128, stderr=" alert. For python 2.3 it works fine (modulo the new 2.4 syntax of course). Both 2.3 and 2.4 are built from source on Cygwin, not...
6
2392
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 1234567'\0''\0''\0''\0''\0''\0''\0'...'\0' This is my first attempt: /* file.c -> file.exe */ #include <stdio.h>
16
3929
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, "#define EXIT_SUCCESS 0" and EXIT_FAILURE is, "#define EXIT_FAILURE 1". I have, however, been told that a few platforms define the two in reverse (#define EXIT_SUCCESS 1 and #define EXIT_FAILURE 0). If this is true, I would expect that it would...
10
15906
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 that AcroComm will sometimes stop polling in the middle of the process and terminate. The programing manual for the app says that it sends a code to the operating system when it is done that tells what has happend like the following: 0 ...
5
2693
by: # include | last post by:
what is the ((((return any no;))) in the main mean plz Ex. int main() { ; ; ; return ??;
11
3407
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 methods can fail I have to check them to be running ok, like this:
10
1757
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 is playing games trying to impress with funky features. I
46
2188
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, hence: exit(EXIT_FAILURE) exit (EXIT_SUCCESS) Bill
0
8242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7170
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.