develooper Front page | perl.beginners | Postings from December 2002

Re: how to make die really dies on windows?

Thread Previous
From:
Jenda Krynicky
Date:
December 31, 2002 04:55
Subject:
Re: how to make die really dies on windows?
Message ID:
3E11A19B.939.363C1FE7@localhost
From: "Mrtlc" <mrtlc@hotmail.com>
> I have a script gonnadie.pl
> 
> ##gonnadie.pl
> do_sth
> die "blah blah";
> 
> gonnadie.pl is called by a DOS batch file x.bat
> 
> REM - x.bat
> perl gonnadie.pl
> 
> 
> x.bat is called by y.bat
> 
> REM - y.bat
> x.bat
> 
> When y.bat is run, the OS treats x.bat ends sucessfully, how can I
> make y.bat dies when gonnadie.pl dies?

If you do it like this the x.bat never returns.
Try

x.bat:
	@echo off
	echo in x.bat

y.bat
	@echo off
	echo started y.bat
	x.bat
	echo back in y.bat

You have to use
	call x.bat

I'm not sure what exactly do you need but this seems to work fine:

x.bat
	@echo off
	perl -e "if ($ARGV[0] eq 'OK') {print 'OK'} else {die 'empty'}" %1
	if %errorlevel% == 255 goto Error
	echo x.bat OK
	goto End
	:Error
	echo x.bat error
	:End

y.bat
	@echo off
	call x.bat %1
	if %errorlevel% == 255 goto Error
	echo y.bat OK
	goto End
	:Error
	echo y.bat error
	:End

HTH, Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
	-- Terry Pratchett in Sourcery


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About