开发者

ANT Execute failed: java.io.IOException: Cannot run program "cp ": java.io.IOException: error=2, No such file or directory

I'm trying to use ANT to copy files from one directory to another directory 开发者_开发问答on Linux.

Firstly I used copy task, it works fine but the file mode is not preserved. Then I changed to use , and that's where I got stuck.

My target is like:

<target name="test">
    <echo message="${basedir}"/>
    <exec executable="cp " os="Linux" spawn="yes">
        <arg line="-p"/>
        <arg line="/tmp/jmap.dat"/>
        <arg line="/tmp/jmap.dat1"/>
    </exec>
</target>

The output I got is: test: [echo] /Users/bpel/mywork/projects/bpel-psr/utils

/utils/build.xml:38: Execute failed: java.io.IOException: Cannot run program "cp ": java.io.IOException: error=2, No such file or directory

I also tried something like:

<exec executable="cp -p /tmp/jmap.dat /tmp/jmap.dat1"/>

and it doesn't work either, it seems cannot find cp command, but if I manually run cp -p /tmp/jmap.dat /tmp/jmap.dat1, it just works fine.

I've been googling around and found no help.

The similiar question on stackoverflow doesn't solve my problem:


You have a space after the cp command:

<exec executable="cp " os="Linux" spawn="yes">

That's telling it run a command called "cp " (with the space). This is confirmed by the error message:

Cannot run program "cp "

In fact, the answer is in the subject of the question :)

Take the space out, it should be fine:

<exec executable="cp" os="Linux" spawn="yes">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜