tags:

views:

1398

answers:

3

I currently have this in my Ant build script:

<exec dir="${basedir}" executable="perl">
    <arg line="${basedir}/version.pl -major"/>
</exec>

However, when that runs, I get this error message:

[exec] Could not open -major
[exec] Result: 2

To me, that says that what I have is trying to run a file called -major, which doesn't exist. The file is version.pl which takes an argument of -major.

How can I alter this to run version.pl with the argument -major?

Note that I am running the ant script on a Solaris machine, however cross-platform or solutions for other OSes are welcome for posterity.

A: 

You can try this:

<exec executable="perl" dir="${basedir}">
    <arg value="version.pl"/>
    <arg value="-major"/>
</exec>

On windows that is

Tommy
I should have specified that I'm running on Solaris. However, it's valid advice, especially since I didn't specify, so I'm not going to downvote.
Thomas Owens
Also, this is the same thing that was suggested by Ville Laurikari (now deleted) that does not work. The same error message is produced.
Thomas Owens
A: 

Try this if it works:

<exec dir="${basedir}" executable="./test.pl">
   <arg line="-major"/>
</exec>

From the ant exec doc:

dir: the directory in which the command should be executed.

So i guess it does a cd to the $dir and exec the $executable (shebang set)

ccheneson
Same result as before.
Thomas Owens
The above works on Ubuntu gutsy - Ant version 1.7.0 Which version of ant are you using?
ccheneson
1.5.4, I guess. I can see about getting Ant upgraded on the server.
Thomas Owens
+1  A: 

I made a quick little Perl script that didn't do a whole lot and ran it just fine passing command line arguments to it using Ant 1.5 on a Solaris box.

<project name="perly" basedir="." default="run">
    <target name="run">
        <exec executable="perl" dir="${basedir}">
            <arg value="version.pl"/>
            <arg value="-major"/>
        </exec>
    </target>
</project>

$ ant run

What I can't quite understand is how you are getting "Could not open -major". Is this a custom die message or something? Is there supposed to be a filename passed instead of major?

geowa4