You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Frank Schaare <Fr...@htp-tel.de> on 2005/08/14 23:21:14 UTC

Open a shell and run a batchfile

Hi,

i´d like to automate some tasks under Win 2000 Server. A dos box should 
open and a batch file should be executed therwith the user can read the 
batchfiles output.

There are tons of examples like this:
<exec executable="cmd">
	<arg line="/c test.bat" />
</exec>

i´ve tried several mutations of these examples, but none of them opened 
the expectet cmd-box for me.

In fact, tis topic should be FAQ, but i searched the arcives until 2000 
without finding a suitable answer.

Is it possible to open a cmd-box in Win2K Server ? Do you know any 
relatet threads, articles, sites etc which deal with this problem ?

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


Re: Open a shell and run a batchfile

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Even better!  I hadn't seen that.

One suggestion... adding spawn="true" to the exec tag should cause the
script to continue even while the spawned window has not been closed...
yep, just tried it, at least on XP that's the case.

Frank

On Mon, August 15, 2005 1:57 am, Ruchira Amarasinghe said:
> Hi Frank,
> My suggestion to a similar question "How to exec a command in a new
> window?" is :
> http://mail-archives.apache.org/mod_mbox/ant-user/200207.mbox/%3c3D48A461.7070000@beyondm.net%3e
>
> quoting the above:
>
>>Try something like,
>>
>>        <exec os="Windows 2000" dir="c:/java/" executable="cmd.exe">
>>            <arg line="/c start setup.bat"/>
>>        </exec>
>>
>>The 'start' opens a new window. But ant won't exit until all windows
>>created are closed.
>>
> Regards,
> Ruchira
>
>
> Frank Schaare wrote:
>
>> Hi,
>>
>> i´d like to automate some tasks under Win 2000 Server. A dos box
>> should open and a batch file should be executed therwith the user can
>> read the batchfiles output.
>>
>> There are tons of examples like this:
>> <exec executable="cmd">
>>     <arg line="/c test.bat" />
>> </exec>
>>
>> i´ve tried several mutations of these examples, but none of them
>> opened the expectet cmd-box for me.
>>
>> In fact, tis topic should be FAQ, but i searched the arcives until
>> 2000 without finding a suitable answer.
>>
>> Is it possible to open a cmd-box in Win2K Server ? Do you know any
>> relatet threads, articles, sites etc which deal with this problem ?
>>
>> ---------------------------------------------------------------------
>> 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


Re: Open a shell and run a batchfile

Posted by Ruchira Amarasinghe <ru...@beyondm.net>.
Hi Frank,
My suggestion to a similar question "How to exec a command in a new 
window?" is :
http://mail-archives.apache.org/mod_mbox/ant-user/200207.mbox/%3c3D48A461.7070000@beyondm.net%3e

quoting the above:

>Try something like,
>
>        <exec os="Windows 2000" dir="c:/java/" executable="cmd.exe">
>            <arg line="/c start setup.bat"/>
>        </exec>
>
>The 'start' opens a new window. But ant won't exit until all windows 
>created are closed.
>
Regards,
Ruchira


Frank Schaare wrote:

> Hi,
>
> i´d like to automate some tasks under Win 2000 Server. A dos box 
> should open and a batch file should be executed therwith the user can 
> read the batchfiles output.
>
> There are tons of examples like this:
> <exec executable="cmd">
>     <arg line="/c test.bat" />
> </exec>
>
> i´ve tried several mutations of these examples, but none of them 
> opened the expectet cmd-box for me.
>
> In fact, tis topic should be FAQ, but i searched the arcives until 
> 2000 without finding a suitable answer.
>
> Is it possible to open a cmd-box in Win2K Server ? Do you know any 
> relatet threads, articles, sites etc which deal with this problem ?
>
> ---------------------------------------------------------------------
> 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


Re: Open a shell and run a batchfile

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Ah, sorry about that, I must have been half asleep... for some reason I 
thought you were asking to list a directory, now I see you want to run 
an arbitrary batch file.  Sorry, my bad.

However, I think what I posted still works just the same... just alter 
what's in test.vbs to execute, instead of "dir" it's your batch file... 
I'm almost completely certain that will work exactly the same.

Frank

Frank W. Zammetti wrote:
> Hi Frank (from one Frank to another!),
> 
> I don't see any way to do that directly from Ant, but maybe someone else 
> does.  Assuming there is no easy answer, here's one round-about way to 
> pull it off...
> 
> Ant script:
> 
>   <project name="test" default="showdir">
>     <target name="showdir">
>       <exec executable="cmd.exe">
>         <arg line="/c test.vbs" />
>       </exec>
>     </target>
>   </project>
> 
> And test.vbs is:
> 
>   dirToList = "c:\"
>   Set wshShell = WScript.CreateObject("WSCript.shell")
>   wshshell.run "cmd.exe /k dir " & dirToList, 1, false
>   Set wshshell = nothing
> 
> Change dirToList as appropriate, or passing it in as a command line 
> argument would probably be even better (and I'd bet more appropriate 
> since I'm guessing you want to determine what directory to list from the 
> Ant script?) and you should be all set.
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


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


Re: Open a shell and run a batchfile

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Hi Frank (from one Frank to another!),

I don't see any way to do that directly from Ant, but maybe someone else 
does.  Assuming there is no easy answer, here's one round-about way to 
pull it off...

Ant script:

   <project name="test" default="showdir">
     <target name="showdir">
       <exec executable="cmd.exe">
         <arg line="/c test.vbs" />
       </exec>
     </target>
   </project>

And test.vbs is:

   dirToList = "c:\"
   Set wshShell = WScript.CreateObject("WSCript.shell")
   wshshell.run "cmd.exe /k dir " & dirToList, 1, false
   Set wshshell = nothing

Change dirToList as appropriate, or passing it in as a command line 
argument would probably be even better (and I'd bet more appropriate 
since I'm guessing you want to determine what directory to list from the 
Ant script?) and you should be all set.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

Frank Schaare wrote:
> Hi,
> 
> i´d like to automate some tasks under Win 2000 Server. A dos box should 
> open and a batch file should be executed therwith the user can read the 
> batchfiles output.
> 
> There are tons of examples like this:
> <exec executable="cmd">
>     <arg line="/c test.bat" />
> </exec>
> 
> i´ve tried several mutations of these examples, but none of them opened 
> the expectet cmd-box for me.
> 
> In fact, tis topic should be FAQ, but i searched the arcives until 2000 
> without finding a suitable answer.
> 
> Is it possible to open a cmd-box in Win2K Server ? Do you know any 
> relatet threads, articles, sites etc which deal with this problem ?
> 
> ---------------------------------------------------------------------
> 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