# Using Ant from Ruby

**URL:** <https://www.ruby-forum.com/t/using-ant-from-ruby/95536>\
**Category:** Ruby\
**Created:** [June 5, 2006, 5:29pm UTC](https://www.ruby-forum.com/t/using-ant-from-ruby/95536 "2006-06-05T17:29:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 5, 2006, 5:29pm UTC](https://www.ruby-forum.com/t/using-ant-from-ruby/95536/1 "2006-06-05T17:29:17Z")

</div>

Hi

I am writing a Ruby script to automate some process. Part of it involves  
running an ant script ( the java build tool from apache). But, I am  
finding it difficult to make it work.

I tried system(‘ant’) but it didn’t work. It just returned a false. I  
have  
checked that ant is there in my system path.  
Another strange thing is that it works when I provide some input or  
output  
redirections. e.g. if I run system(‘ant \> abc.txt’), the command runs.

I also tried `ant` but that also didn’t work and returned the following  
error.  
Errno::ENOEXEC: Exec format error - ant

In this case also `ant < abc.txt` or `ant > abc.txt` works!!

I am using Windows 2000 machine and have cygwin and 4nt installed. I am  
running these commands on irb promt on 4nt.  
Can anyone please help me in this regard.

Thanks and regards  
Sanchit Misra

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 5, 2006, 5:46pm UTC](https://www.ruby-forum.com/t/using-ant-from-ruby/95536/2 "2006-06-05T17:46:07Z")

</div>

On Monday 05 June 2006 17:27, removed\_email\_address@domain.invalid wrote:

> command runs.
> 
> I also tried `ant` but that also didn’t work and returned the  
> following error.  
> Errno::ENOEXEC: Exec format error - ant
> 
> In this case also `ant < abc.txt` or `ant > abc.txt` works!!
> 
> I am using Windows 2000 machine and have cygwin and 4nt installed.  
> I am running these commands on irb promt on 4nt.  
> Can anyone please help me in this regard.

I guess the “ant” command on Windows resolves to an ant.bat or ant.cmd  
file. Others had similar problems with the “system” method.  
Try to run:  
system “ant.bat”  
or  
system “ant.cmd”

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 5, 2006, 5:49pm UTC](https://www.ruby-forum.com/t/using-ant-from-ruby/95536/3 "2006-06-05T17:49:16Z")

</div>

maybe you can try:

`cmd /c ant`

removed\_email\_address@domain.invalid å??é?:

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 5, 2006, 6:02pm UTC](https://www.ruby-forum.com/t/using-ant-from-ruby/95536/4 "2006-06-05T18:02:32Z")

</div>

system “ant.bat” worked!! thanks a lot

Sanchit

Stefan L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
06/05/2006 09:13 PM  
Please respond to  
removed\_email\_address@domain.invalid

To  
removed\_email\_address@domain.invalid (ruby-talk ML)  
cc

Subject  
Re: Using Ant from Ruby

On Monday 05 June 2006 17:27, removed\_email\_address@domain.invalid wrote:

> command runs.
> 
> I also tried `ant` but that also didn’t work and returned the  
> following error.  
> Errno::ENOEXEC: Exec format error - ant
> 
> In this case also `ant < abc.txt` or `ant > abc.txt` works!!
> 
> I am using Windows 2000 machine and have cygwin and 4nt installed.  
> I am running these commands on irb promt on 4nt.  
> Can anyone please help me in this regard.

I guess the “ant” command on Windows resolves to an ant.bat or ant.cmd  
file. Others had similar problems with the “system” method.  
Try to run:  
system “ant.bat”  
or  
system “ant.cmd”

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 5, 2006, 6:06pm UTC](https://www.ruby-forum.com/t/using-ant-from-ruby/95536/5 "2006-06-05T18:06:22Z")

</div>

`cmd /c ant` also worked!  
thanks

sanchit

ruby-talk ML [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
06/05/2006 09:22 PM  
Please respond to  
removed\_email\_address@domain.invalid

To  
removed\_email\_address@domain.invalid (ruby-talk ML)  
cc

Subject  
Re: Using Ant from Ruby

maybe you can try:

`cmd /c ant`

removed\_email\_address@domain.invalid å??é?:

> Hi
> 
> I am writing a Ruby script to automate some process. Part of it involves

> running an ant script ( the java build tool from apache). But, I am  
> finding it difficult to make it work.
> 
> I tried system(‘ant’) but it didn’t work. It just returned a false. I  
> have  
> checked that ant is there in my system path.  
> Another strange thing is that it works when I provide some input or  
> output
