On Sun, 21 Apr 2002, Michael Lamertz wrote:
> On Sat, Apr 20, 2002 at 08:07:09PM -0400, Paul Lombardo wrote:
> > 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.
>
> Nope, that won't work, since the Environment is only passed over to
> child processes, not parents.  Since the NT shell lacks critical
> features like backquotes, the only thing I see that's left is a kind of
> status file that you write on error.  You can check the existance and
> content of that file if your script returns an error.

Hm, I got bitten by the missing backquotes a while ago too...

But I'm not sure if they are what Paul wants, that depends on what he
wants to do I think.

If the Perl script is the last thing the batch file executes, I don't
really see a problem, since you could just let the Perl script emit
the error/success message. That might leave you with the problem of
exiting the batch script with the correct exit code, but I don't know
how the NT shell does these things (Bash shells exit with the exit
code their last command exited with IIRC; an eval might also take care
of the problem).

If the future course of actions of the batch script depends on the
success/failure of the Perl script, then you could do that with a
temporary file, like Micheal suggested, or you might also ressort to
exit codes -- there has to be *some* way to capture them, don't you
think?

Or you could pipe the output of the Perl script to another script (be
it Perl or batch or what-not) that could interpret it... But really,
I'd just get rid of the NT shell and re-write the thing in all-Perl
:-)

        Elias

-- 
"There are people who don't like capitalism, and there are people who don't like PCs,
but there's no one who likes the PC who doesn't like Microsoft."
 -- Bill Gates


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to