Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 3981 invoked from network); 11 Mar 2005 16:55:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 11 Mar 2005 16:55:06 -0000 Received: (qmail 28717 invoked by uid 500); 11 Mar 2005 16:55:03 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 28381 invoked by uid 500); 11 Mar 2005 16:55:01 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 28368 invoked by uid 99); 11 Mar 2005 16:55:01 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from fed1rmmtao08.cox.net (HELO fed1rmmtao08.cox.net) (68.230.241.31) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 11 Mar 2005 08:55:00 -0800 Received: from JOHN.cox.net ([70.176.68.172]) by fed1rmmtao08.cox.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050311165446.NPZI18934.fed1rmmtao08.cox.net@JOHN.cox.net> for ; Fri, 11 Mar 2005 11:54:46 -0500 Message-Id: <6.0.2.0.2.20050311084249.0236b850@pop.west.cox.net> X-Sender: cortell@pop.west.cox.net X-Mailer: QUALCOMM Windows Eudora Version 6.0.2.0 Date: Fri, 11 Mar 2005 09:20:08 -0700 To: "Ant Users List" From: John Cortell Subject: RE: launching Ant from a perl script In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Sten, thanks for the added info. It seems putting an 'exit /b' at the end of ant.bat has the same effect as putting a 'goto: eof' which has the same effect as leaving ant.bat unmodified (sort of like putting a return statement at the end of a C/C++ function that returns void). Again, no surprise there. So, it appears here's what's happening. Perl invokes a command shell to execute the bat file (ant.bat). The return code from that command shell process is NOT turning out to be %errorlevel%. So, while the ant application has failed, Perl never gets wind of it. Doing an 'exit' at the end of the bat apparently causes the command shell to return %errorlevel% as the return code. Without it, the command shell will return %errorlevel% if no other bat directive follows the failed ant app invocation (and even a simple REM statement can mask out the failure). For proof of this latter point, try invoking the following: [test.bat] dir -xyz REM [test.pl] `test.bat`; print("error is $?\n"); Running test.pl will print "error is 0" !! Take out the REM statement, and you'll get the expected behavior. Very strange. Put back the REM and add an 'exit' and there too you'll get the expected behavior, although now test.bat will terminate the command window if you run it straight out (not good). Anyway, I realize some of this has strayed significantly from the focus of this mailing list. However, hopefully it does document why running ant.bat from a perl script is problematic (in so far as getting the success status of the ant invocation). As to my previous email, I figured out why invoking ant via runant.pl was having a problem finding tools.jar. Unlike ant.bat, tools.jar does NOT support JAVA_HOME. Instead, it relies on java.exe being in the PATH. (My PATH picks up an old java.exe) The need for java.exe in the PATH is documented at the top of runant.pl, so that's fair. Still, I would expect runant.pl and ant.bat to behave as similar as possible. I.e. I'd expect both to support JAVA_HOME. John At 08:55 AM 3/11/2005, sten.rosendahl@sungard.com wrote: > From the Windows XP on-line help: > >EXIT [/B] [exitCode] > > /B specifies to exit the current batch script instead of > CMD.EXE. If executed from outside a batch script, it > will quit CMD.EXE > > exitCode specifies a numeric number. if /B is specified, sets > ERRORLEVEL that number. If quitting CMD.EXE, sets the >process > exit code with that number. > >Sten Rosendahl > > > > -----Original Message----- > > From: Dick, Brian E. [mailto:Brian.Dick@FMR.com] > > Sent: Friday, March 11, 2005 4:35 PM > > To: Ant Users List > > Subject: RE: launching Ant from a perl script > > > > The "exit" command terminates the command shell and not the bat file. > > You exit a bat file by "goto :eof". > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: user-unsubscribe@ant.apache.org >For additional commands, e-mail: user-help@ant.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org