如何使用 Ant exec 任务执行 Perl 脚本? [英] How can I execute a Perl script using the Ant exec task?

查看:40
本文介绍了如何使用 Ant exec 任务执行 Perl 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在我的 Ant 构建脚本中有这个:

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] 无法打开 -major
[exec] 结果:2

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

对我来说,这说明我正在尝试运行一个名为 -major 的文件,但该文件不存在.该文件是 version.pl,它采用 -major 的参数.

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.

如何更改它以使用参数 -major 运行 version.pl?

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

请注意,我是在 Solaris 机器上运行 ant 脚本,但是我们欢迎跨平台或其他操作系统的解决方案.

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

推荐答案

我制作了一个快速的小 Perl 脚本,它没有做很多事情,并且在 Solaris 机器上使用 Ant 1.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

我不太明白你是如何得到无法打开 - 主要"的.这是自定义 die 消息还是什么?是否应该传递文件名而不是主要文件名?

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?

这篇关于如何使用 Ant exec 任务执行 Perl 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆