2011-11-01 43 views
0

我需要连接两个文件。我使用Ant的exec来达到这个目的,但是我得到以下错误。Ant的exec在复制上返回错误

production: 
[exec] Current OS is Windows 7 
[exec] Executing 'cmd' with arguments: 
[exec] 'copy /B destination\bin\installer.sh+destination.tar.gz Installer.bin' 
[exec] 
[exec] The ' characters around the executable and arguments are 
[exec] not part of the command. 
[exec] Microsoft Windows [Version 6.1.7600] 
[exec] Copyright (c) 2009 Microsoft Corporation. All rights reserved. 
[exec] 

任务看起来是这样的:

<target name="production" depends="tar" > 
    <exec dir="${bin}" executable="cmd"> 
     <arg line="'copy /B destination\bin\installer.sh+destination.tar.gz Installer.bin'"/> 
    </exec> 
</target> 

如何解决这个问题?

回答

4

试试这个,

<target name="production" depends="tar" > 
    <exec dir="${bin}" executable="cmd"> 
    <arg line="/C copy /B destination\bin\installer.sh+destination.tar.gz Installer.bin"/> 
    </exec> 
</target> 

你就需要有/C,表明你是在传递一个命令到CMD.EXE

3

你可以使用ant concat任务来完成更多容易。不要忘记设置binary标志。作为奖励,这将超越Windows。

+2

+1无需重新发明轮子。 – FailedDev