有没有办法让蚂蚁创建一个shell或批处理脚本运行? [英] Is there a way to have Ant create a shell or batch runtime script?

查看:178
本文介绍了有没有办法让蚂蚁创建一个shell或批处理脚本运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让蚂蚁创建一个运行shell或批处理脚本运行而无需手动创建脚本自己。

Is there a way to have Ant create a runtime shell or batch runtime script instead of having to manually create the script myself.

这将是类似于链接文本

推荐答案

是的,它可以做到的。这里有一个简单的例子(你的链接是不是现在的工作... sourceforge的错误时,抛出)。其基本思路是编写使用回声任务的文件,然后使用它运行 EXEC 任务:

Yes it can be done. Here's a simple example (your link is not working right now ... sourceforge error thrown). The basic idea is to write the file using the echo task, then run it using the exec task:

<property name="myls" value="myls.sh" />
<echo file="${myls}">
ls
</echo>
<exec executable="sh">
    <arg value="${myls}"/>
</exec>

在运行给出了以下方面的工作目录仅包含构建文件和脚本:

When run gives the following, as the working directory only contains the build file and the script:

Buildfile: build.xml
     [exec] build.xml
     [exec] myls.sh

这当然是特定于UNIX的,但你可以在其他系统上做类似的同样出色 - 对于Windows您会改变可执行文件 CMD 我相信。您可以借此进一步,如果需要,也传递参数给你的新脚本。例如:

This is of course unix-specific, but you could do similar equally well on other systems - for windows you'd change the executable to cmd I believe. You can take this further and pass arguments to your new script too if needed. For example:

<property name="myls" value="myls.sh" />
<echo file="${myls}">
ls $@
</echo>
<exec executable="sh">
    <arg value="${myls}"/>
    <arg value="b*"/>
</exec>

在运行,现在只能看到构建文件:

When run now only sees the build file:

Buildfile: build.xml
     [exec] build.xml

这篇关于有没有办法让蚂蚁创建一个shell或批处理脚本运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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