Hm ... Do you have some link(s) to cmd.exe shell documentations ? (even advanced !) José. [EMAIL PROTECTED] a écrit : On 21 April 2002 01:07, Paul Lombardo [mailto:[EMAIL PROTECTED]] wrote: > > I am new to this group and coming back to perl after a year > long hiatus. > > I am using perl on an NT4 server and > > I have a batch file that calls a perl script. (this works flawlessly) > > The perl script does some tasks (this also works as planned) > > The batch script exits (works well) > > I need to do the following: > > if the perl script fails I need to pass a variable to the > batch file so it > can exit with a proper failure message > when the perl script succeeds I need to pass a variable to > the batch file > so it can exit with a proper success message. > > I have tried setting ENV{ERRORLEVEL} on failure I have tried > exit() and > nothing seems to work. > > Has anyone seen this before? Can it be done? How? >
exit n from perl will return a status to the cmd.exe shell, and you can test for this value with if errorlevel n in the batch file. Hence, given ErrLevel.pl: #!perl print "ARGV[0] = $ARGV[0]\n"; exit $ARGV[0]; and ErrLevel.cmd: perl -w ErrLevel.pl %1% if ERRORLEVEL 2 echo ErrorLevel 2 if ERRORLEVEL 1 echo ErrorLevel 1 echo end of script Running "ErrLevel 1" gives output: ARGV[0] = 1 ErrorLevel 1 end of script Note, if errorlevel n checks for return code >= n, hence "ErrLevel 2" gives: ARGV[0] = 1 ErrorLevel 1 ErrorLevel 2 end of script Thus usually, the script uses if errorlevel n goto label to branch away and another label after the if's for the return goto to target. Hope this helps. Richard Cox Senior Software Developer Dell Technology Online All opinions and statements mine and do not in any way (unless expressly stated) imply anything at all on behalf of my employer -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------- Yahoo! Mail -- Une adresse @yahoo.fr gratuite et en français !