Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl scripts called in a batch-file.

Status
Not open for further replies.

abc73

Programmer
Apr 28, 2004
89
0
0
US
Hi,
I have a batch script i.e. p.bat in which I call perl scripts along with other commands e.g.

Code:
.....
.....
test1.pl
test2.pl
test.pl
java Print
....
....

when I execute the above script the perl scripts gets executed in a sequence and finally a java program. How can I do that if test1.pl executed successfully then and only then execute test2.pl and so on. If any errors in executing any of the commands in the batch-file I don't want to proceed the execution. Is there a way to handle this in a batch file. Thanks
 
you can have perl programs return values when they exit, using exit() command. Based on these return values, construct the consequent execution logic.
 
how can I get this return value in the batch file
thanks
 
something like:

@ECHO OFF
REM - Starting this batch job

:BEGIN
CLS
IF ERRORLEVEL ==3 GOTO THREE
IF ERRORLEVEL ==2 GOTO TWO
IF ERRORLEVEL ==1 GOTO ONE
GOTO END


:THREE
test1.pl
GOTO END

:TWO
test2.pl
GOTO END

:ONE
test.pl

:END
java Print
REM This batch job is complete





-------------------------------
In your perl scripts, as azzazzello suggested, you would have to exit will exit codes like:

test1.pl
blah blah code code
exit(3);



HTH - Stiddy

 
Sorry..

take the GOTO END commands from
:THREE and :TWO
 
Are you able to run the Perl scripts in a batch file with your firewall on? I am having problems doing this ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top