ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dalton, Tom" <tdal...@hp.com>
Subject RE: exec - Cannot run program 'start' CreateProcess error=2
Date Thu, 17 Dec 2009 10:18:44 GMT
Sorry,

I misunderstood what you are doing. I don't think you need to use 'start' or 'cmd' to launch
whatever process you are launching.

So in the examples below: 

<exec dir="<path/to/start>"
      executable="./start"
      output="./testproj.log">
  <arg line=" cmd /c notepad"/>
</exec>

The executable you are trying to run is notepad. So then the exec task will be:

<exec executable="notepad"
      output="./testproj.log">
</exec>

This works because notepad is in the system path - e.g. if you were on the command line, then
you can run notepad from anywhere, because windows knows to always look for programs in certain
locations, and notepad is in one of these locations. It sounds like the program you are trying
to run through the exec command is not in one of these locations. Therefore, you either need
to run the command from it's containing directory, and add ./ to the front of the executable
name, or you need to specify the full path to the executable.

For example you want to run the executable in "c:/my_program/bin/test.exe", with the argument
line "-test 3", and output to "c:/my_program/bin/testproj.log". You can do one of the two
following things:

<exec dir="c:/my_program/bin"
      executable="./test.exe"
      output="./testproj.log">
  <arg line="-test 3"/>
</exec>

OR

<exec executable="c:/my_program/bin/test.exe"
      output="c:/my_program/bin/testproj.log">
  <arg line="-test 3"/>
</exec>

Note that in the second example, the test.exe will inherit the current working directory from
the calling ant process.

In both examples, the ant script will resume whenever the called executable terminates (e.g.
when test.exe terminates). If the called executable is intended to be run as a server 'server'
(a background, persistent process), then you may have additional work to do. You may need
to wrap the server executable with a script that manages starting the server and checking
that it is running successfully, before returning control to ant by terminating itself. Of
course, you still have the possibility that the server will subsequently die unexpectedly...

Hope that helps,

Tom



-----Original Message-----
From: as rao [mailto:asrao.yogi@gmail.com] 
Sent: 17 December 2009 07:28
To: Ant Users List
Subject: Re: exec - Cannot run program 'start' CreateProcess error=2

Though  *vmlauncher="false"* worked for me, it has the following problem:

This means control is being done by OS (not JVM). My script start multiple managed servers
in a sequence. Once the 1st server is started and in the 'RUNNING' mode, Ant should get the
control back so that it can start the 2nd server. If JVM has control, it passes the control
back to ant, as it can identify the managed server has been started. In this case, as I give
*vmlauncher="false"
*my 1st server is getting started, but the control is not coming back to Ant. So, 2nd and
3rd servers are not getting started and Ant is waiting forever to get the control back.

Also, *spawn="true"* doesn't work for my context, because, I have output/error redirection.

Any suggestions pl.

cheers
a s

On Wed, Dec 16, 2009 at 6:39 PM, as rao <asrao.yogi@gmail.com> wrote:

> Hi
>
> Thank you all.
>
> The build.xml is given by the vendor of the app server, and is a 
> complex build file. I am OK to make changes, but only minor changes.
>
> I tried adding attribute *vmlauncher="false"* to exec and it worked 
> for me.
>
> cheers
> a s
>
>
>
>
>
> On Wed, Dec 16, 2009 at 2:59 PM, Dalton, Tom <tdalton@hp.com> wrote:
>
>> You probably need to specify the working dir for the start executable 
>> and might also need to add ./ to start if wherever it is located 
>> isn't in the system PATH.
>>
>> E.g.
>> <exec dir="<path/to/start>"
>>       executable="./start"
>>      output="./testproj.log">
>>  <arg line=" cmd /c notepad"/>
>> </exec>
>>
>> Hope that helps!
>>
>> Tom
>>
>> -----Original Message-----
>> From: as rao [mailto:asrao.yogi@gmail.com]
>> Sent: 16 December 2009 07:40
>> To: user@ant.apache.org
>> Subject: Re: exec - Cannot run program 'start' CreateProcess error=2
>>
>> Hi
>>
>> To simplifying the problem statement, when I try to run the default 
>> target in the following build file:
>>
>> ---------------
>> <project name="test"  basedir="." default="test-target">
>>
>> <target name="test-target">
>>        <exec executable="start"
>>          output="./testproj.log">
>>      <arg line=" cmd /c notepad"/>
>>        </exec>
>> </target>
>> </project>
>> ---------------
>>
>> I am getting same error.
>>
>> cheers
>> a s
>>
>>
>> On Wed, Dec 16, 2009 at 11:51 AM, as rao <asrao.yogi@gmail.com> wrote:
>>
>> > Hi
>> >
>> > During starting of app server using ant / build.xml (given by the 
>> > vendor), I faced the following issue:
>> >
>> > My env is windows XP, ant 1.7.1
>> > I am running a build.xml (given by the vendor) to start an app 
>> > server, from DOS prompt. I got the following error:
>> >
>> > ---------------------------------------------------------------
>> > BUILD FAILED
>> > D:\Installations\11gPS1\build.xml:538: The following error occurred 
>> > while executing this line:
>> > D:\Installations\11gPS1\build.xml:555: The following error occurred 
>> > while executing this line:
>> > D:\Installations\11gPS1\build.xml:635: Execute failed:
>> java.io.IOException:
>> > Cannot run program "start": CreateProcess error=2, The system 
>> > cannot find the file specified
>> > ---------------------------------------------------------------
>> >
>> > when I looked into the build.xml I found that its exec trying to 
>> > run 'start' command using which it intend to run a .cmd file to 
>> > start the app server .
>> > And interestingly from the same DOS prompt I could run "start" 
>> > command to open a notepad, and so I tend to think that there are no 
>> > issues with PATH, shell, etc.
>> >
>> > Any suggestions?
>> >
>> >
>> > cheers
>> > a s
>> >
>>
>>
>>
>> --
>> regards
>> a s rao
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
>> additional commands, e-mail: user-help@ant.apache.org
>>
>>
>
>
> --
> regards
> a s rao
>



--
regards
a s rao

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message