Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 37497 invoked from network); 25 Apr 2007 07:57:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Apr 2007 07:57:39 -0000 Received: (qmail 74893 invoked by uid 500); 25 Apr 2007 07:57:41 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 74868 invoked by uid 500); 25 Apr 2007 07:57:41 -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 74853 invoked by uid 99); 25 Apr 2007 07:57:41 -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:57:41 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of chris.dudley@gmail.com designates 64.233.162.230 as permitted sender) Received: from [64.233.162.230] (HELO nz-out-0506.google.com) (64.233.162.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Apr 2007 00:57:33 -0700 Received: by nz-out-0506.google.com with SMTP id j2so186974nzf for ; Wed, 25 Apr 2007 00:57:12 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=OqvkNXoxCEPN5fuNGsmH0UxvUlcCxcFHH8IpymcAJpB6tGvC+/nUVJYNEojnhoUdJ9rvd0nlRc0YZskOGjevr4QpIABMXqXnBjRW/KEhYwpy8o5gBTW6Xhv/hMfUhZJ9/giIAt8HGyCRdfIE+D/QFeSAbEZCIMgyy1/Nr3WCEPs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=UoTlZ0YnyzPhTPQlqM9lq/Gv/oI6T3qBJujT9tBc1UQEsBtbVO2eLe9LDJEJKtaPwFAKpRHAHM8LRdh7fTJ4FYjr/8ohCGSDsBf4zky/dEC42hhQ7/4VZlCkqKi5rdwN/57eNe7SgP1/79gK/o3IUezFPhLoya7yIiEBQrGJ8kE= Received: by 10.114.66.2 with SMTP id o2mr117545waa.1177487832346; Wed, 25 Apr 2007 00:57:12 -0700 (PDT) Received: by 10.114.200.16 with HTTP; Wed, 25 Apr 2007 00:57:12 -0700 (PDT) Message-ID: <9b6e13750704250057u677ed043g237c80033cc93302@mail.gmail.com> Date: Wed, 25 Apr 2007 08:57:12 +0100 From: "Chris Dudley" To: "Ant Users List" Subject: Re: Exec on Windows ignores return code? In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: X-Virus-Checked: Checked by ClamAV on apache.org Removing the /B would just mean it would return 0 all the time. As it happens I can't actually modify the batch file (its one that ships with another product that I just happen to be invoking). I suppose I could use a wrapper batch file that caught the return code and then wrote a file out - but thats seems incredibly hacky! Is there no way for ANT to actually detect batch file return codes? Thanks for all the help by the way! On 4/25/07, Jan.Materne@rzf.fin-nrw.de wrote: > 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 buil= dfile could check > that via . > > > Jan > > >-----Urspr=FCngliche Nachricht----- > >Von: Chris Dudley [mailto:chris.dudley@gmail.com] > >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 > > 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 > >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 > >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 > >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? > >> > > >> > >>--------------------------------------------------------------------- > >> >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 > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org