Return-Path: Mailing-List: contact ant-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list ant-user@jakarta.apache.org Received: (qmail 67830 invoked from network); 30 Jan 2001 16:07:17 -0000 Received: from f136.law12.hotmail.com (HELO hotmail.com) (64.4.19.136) by h31.sny.collab.net with SMTP; 30 Jan 2001 16:07:17 -0000 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 30 Jan 2001 08:06:53 -0800 Received: from 62.213.135.66 by lw12fd.law12.hotmail.msn.com with HTTP; Tue, 30 Jan 2001 16:06:53 GMT X-Originating-IP: [62.213.135.66] From: "=?iso-8859-1?B?TWljaGHrbCBTbWl0aA==?=" To: ant-user@jakarta.apache.org Subject: Re: Possible bug - Problem with exec and dir attribute Date: Tue, 30 Jan 2001 17:06:53 +0100 Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Message-ID: X-OriginalArrivalTime: 30 Jan 2001 16:06:53.0953 (UTC) FILETIME=[A99B3710:01C08AD6] X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N I haven't done either of the two options you specify (give the full path OR have it in the path) and it DOES work for me. The only thing I had to do was create a dummy batch file and put it in my working directory. Regards, Micha�l >Michael, > >I am attaching a report I submitted to Sun about this problem and their >reply. The short answer is that you need to give the full path to your >executable or have it in your PATH for the exec to work > >-------------------------------------------------------------. > >Hi Conor MacNeill, > >The evaluation of your bug report has been completed. > >The problem you encountered is not a bug, and the output >is the expected behavior of runtime.exec. > >If you have further question about this issue, please let us know. > >Thank you for taking the time to report this problem. > >----------------- Original Bug Report------------------- > >category : java >subcategory : classes_lang >release : 1.3 >type : bug >synopsis : runtime.exec is inconsistent when passing a working directory >description : java version "1.3.0" >Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C) >Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode) > >Runtime.exec is a little inconsistent in how it finds the given executable >command, when provided a working directory. Consider the following setup: >A current directory with a batch file, super.bat >A subdirectory, subdir with a batch file sub.bat > >If I execute, through Runtime.exec, super.bat with either a null working >directory or a directory of ".", it functions fine. If I try to execute >sub.bat >in subdir, however, it fails without an exception. Strangely, if I try to >execute super.bat in subdir, it fails in a different way and without an >exception. Finally, passing the full path to sub.bat and executing in >subdir >works. > >The following Java code illustrates this behaviour (you will need to create >the >batch files as appropriate): > >import java.io.*; > >public class Test { > public static final void main( String[] args ) { > execCommand("super.bat", null); > execCommand("super.bat", new File(".")); > execCommand("sub.bat", new File("subdir")); > execCommand("super.bat", new File("subdir")); > > File subbatFile = new File("subdir/sub.bat"); > execCommand(subbatFile.getAbsolutePath(), new File("subdir")); > } > > static private void execCommand(String command, File dir) { > System.out.println("------------------------------------"); > System.out.println("Executing " + command + " in " + dir); > System.out.println("------------------------------------"); > Runtime runtime = Runtime.getRuntime(); > byte[] buffer = new byte[2048]; > try { > Process process = runtime.exec(new String[] {command}, > new String[0], dir); > InputStream is = process.getInputStream(); > int bytesRead; > while ((bytesRead = is.read(buffer)) != -1) { > System.out.write(buffer, 0, bytesRead); > } > System.out.println("++++++++ Standard Error ++++++++++"); > is = process.getErrorStream(); > while ((bytesRead = is.read(buffer)) != -1) { > System.out.write(buffer, 0, bytesRead); > } > } > catch (Exception e) { > e.printStackTrace(); > } > System.out.println("===================================="); > } >} >workaround : The command to be executed should either be specified exactly, >or exist on the >user's path. In the end, if this doesn't work, it shouldn't work for all >scenarios where the full path is not specified. >suggested_val : >dateCreated : 2001-01-17 05:17:26.6 >dateEvaluated : 2001-01-17 10:03:04.898 > > >----- Original Message ----- >From: "Micha�l Smith" >To: >Sent: Wednesday, January 31, 2001 12:37 AM >Subject: Possible bug - Problem with exec and dir attribute > > > > I'm trying to execute a batch file with the following: > > > > > os="Windows 2000"/> > > > > I'm noticing some very weird behavior. It fails unless I have a file > > test.bat in my current directory. When I have the test.bat locally, the > > build succeeds and does in fact run the correct batch file (I changed >them > > to echo different messages so I could verify which one is run). When I > > rename the test.bat that is in my local directory then the build stops > > working. I reproduced this with several different batch files so I'm >sure > > it's not a coincidence. > > > > Very strange. I'm using the latest build, Jan 22. Has anyone else seen > > this problem? > > > > Thanks, > > Micha�l > > > > > > >_________________________________________________________________________ > > Get Your Private, Free E-mail from MSN Hotmail at >http://www.hotmail.com. > > > > > _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.