473,326 Members | 2,111 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,326 software developers and data experts.

Perl script that calls other Perl scripts, how to handle errors ?

fungazid
Hello guys,

I have a Perl script that calls other Perl scripts:


Expand|Select|Wrap|Line Numbers
  1. ### Main script: ###
  2. my @command;
  3. $command[0]="step1.pl";
  4. $command[1]="step2.pl";
  5.  
  6. system($command[0]);
  7. system($command[1]);
  8.  
If step1.pl is terminated as a result of an error, the main script proceeds to step2.pl as nothing happened. Is there an easy way to know that step1.pl failed before calling step2.pl ?


Thanks,
Fungazid
Nov 5 '07 #1
3 1558
KevinADC
4,059 Expert 2GB
check the return value of the system() function. It's covered in the system() functions documentation.

perloc: system

kind of unusual to use the system() function to run other perl programs from a perl program. You can do that if you want to but you can also use "require", "use", "do", to include other perl programs in your main program.
Nov 5 '07 #2
Thank you,

I assume I should handle errors in this way:
Expand|Select|Wrap|Line Numbers
  1. @args = ("step1.pl");
  2. system(@args) == 0
  3.      or die "system @args failed: $?"
  4. @args = ("step2.pl");
  5. system(@args) == 0
  6.      or die "system @args failed: $?"
  7.  
I wonder what is so unusual in calling system()
Nov 6 '07 #3
KevinADC
4,059 Expert 2GB
There is nothing unusual in calling system(). The problem is more than likely that you do not understand how to use it and what the other opions are that you could be using. system() only returns the exit value of an external process. If your perl programs return 0 for failure then you can use the code you have.
Nov 6 '07 #4

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

Similar topics

3
by: dpackwood | last post by:
Hello, I have two different scripts that do pretty much the same thing. The main perl script is on Windows. It runs and in the middle of it, it then calls out another perl script that then...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
3
by: MarkW | last post by:
I hope this is the correct place to post this: I am developing a web site for a e-commerce business I will be running. The site I'm setting up will be 50% store, 50% content. I'm not sure which...
4
by: Patricia Mindanao | last post by:
I want to call cgi perl scripts on my web hosters server from my HTML web pages (on the the web hosters server too). It occurs sometimes (especially during development phase) that these cgi-perl...
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.