Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 30537 invoked from network); 25 Apr 2007 07:43:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Apr 2007 07:43:57 -0000 Received: (qmail 44032 invoked by uid 500); 25 Apr 2007 07:43:58 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 43989 invoked by uid 500); 25 Apr 2007 07:43:58 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 43956 invoked by uid 99); 25 Apr 2007 07:43:58 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Apr 2007 00:43:58 -0700 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [193.109.238.66] (HELO dnsinet.rzf-nrw.de) (193.109.238.66) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Apr 2007 00:43:51 -0700 Received: from z011100.bk.fin.local (z011100.bk.fin.local [172.18.101.140]) by dnsinet.rzf-nrw.de (8.14.0/8.14.0) with ESMTP id l3P7hSvA004831 for ; Wed, 25 Apr 2007 09:43:28 +0200 Received: from z011034.bk.fin.local ([130.11.7.34]) by z011100.bk.fin.local with Microsoft SMTPSVC(6.0.3790.0); Wed, 25 Apr 2007 09:43:27 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: AW: Exec on Windows ignores return code? Date: Wed, 25 Apr 2007 09:43:28 +0200 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Exec on Windows ignores return code? Thread-Index: AceHDGxRWHCaDGjqQDingkReEO9S1wAAMd2g From: To: X-OriginalArrivalTime: 25 Apr 2007 07:43:27.0833 (UTC) FILETIME=[698A1490:01C7870D] X-Virus-Checked: Checked by ClamAV on apache.org Modify your batch file so that it does not use the /B flag. Alternatively your batch could write a file as error marker and your = buildfile could check that via . Jan=20 >-----Urspr=FCngliche Nachricht----- >Von: Chris Dudley [mailto:chris.dudley@gmail.com]=20 >Gesendet: Mittwoch, 25. April 2007 09:36 >An: Ant Users List >Betreff: Re: Exec on Windows ignores return code? > >So how can I get ANT to detect when the batch file goes bang? >I tried getting ANT to invoke the batch file direct instead of >invoking cmd /c test.bat and that made no difference. > >ANT invokes a bash shell on unix and then runs a shell script in that >and yet return codes work there, just not on Windows. > > > >On 4/25/07, Jan.Materne@rzf.fin-nrw.de=20 > wrote: >> Works for me, BUT you must not use the /B in your batch file. >> Have a look at the help with "help exit" - /B just sets the=20 >error code >> for the _batchfile_, but Ant is not executing the batchfile. >> Ant executes the shell! >> >> >> Jan >> >> >-----Urspr=FCngliche Nachricht----- >> >Von: Chris Dudley [mailto:chris.dudley@gmail.com] >> >Gesendet: Dienstag, 24. April 2007 19:30 >> >An: user@ant.apache.org >> >Betreff: Exec on Windows ignores return code? >> > >> >Apologies if this is a FAQ or a known problem but I couldn't find >> >anything useful in the archives, google or in bugzilla. >> > >> >I am having trouble with the exec task on Windows. >> >It seems to me that regardless of what the executable returns, ANT >> >always claims the return code on Windows is 0. >> > >> >The code below runs a simple test batch file. The batch file is >> >hardcoded to always return 1. Running the batch file from a command >> >prompt and then echoing %ERRORLEVEL% does indeed show the=20 >return code >> >to be 1 and not 0. >> > >> >So where is ANT getting the 0 return code from? >> > >> >I have tried a similar test on Linux and UNIX (not using a batch >> >script of course) and it works perfectly. >> > >> >But yet I don't think this is a peculiarity of Windows since >> >%ERRORLEVEL% is being set correctly - ANT just isn't picking it up. >> > >> >I have tried ANT 1.6.2, 1.6.5 and 1.7.0 - all seem to=20 >exhibit the same >> >behaviour. >> > >> >I am hoping there is a workaround or a simple solution to something >> >stupid I've done! >> > >> >Thanks! >> > >> >This is the ANT snippet: >> > >> > >> > >> > >> > >> > >> > >> >test.bat contains just one line: >> > >> >exit /B 1 >> > >> >This is what comes out when ant is run with debug on: >> > >> > [exec] Current OS is Windows XP >> > [exec] Executing 'cmd' with arguments: >> > [exec] '/c' >> > [exec] 'C:\install\test.bat' >> > [exec] >> > [exec] The ' characters around the executable and arguments are >> > [exec] not part of the command. >> >Execute:Java13CommandLauncher: Executing 'cmd' with arguments: >> >'/c' >> >'C:\install\test.bat' >> > >> >The ' characters around the executable and arguments are >> >not part of the command. >> > [exec] >> > [exec] C:\>exit /B 1 >> >Setting project property: error -> 0 >> > [echo] error=3D0 >> > >> >I really want ANT to abort the build if the executable returns >> >non-zero, which works fine on UNIX but I need it to work on Windows >> >too. >> > >> >Any ideas please? >> > >>=20 >>--------------------------------------------------------------------- >> >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 >> >> > >--------------------------------------------------------------------- >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