2

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.

Thomas Owens
  • 114,398
  • 98
  • 311
  • 431

3 Answers3

5

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
  • 40,390
  • 17
  • 88
  • 107
0

You can try this:

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

On windows that is

Tommy
  • 4,011
  • 9
  • 37
  • 59
  • 1
    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 Aug 04 '09 at 13:23
  • 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 Aug 04 '09 at 14:09
0

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
  • 49,072
  • 8
  • 63
  • 68