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: