Search code examples
puttynantpscp

Target directory with space in PuTTY pscp via NAnt


This target is OK (D:\Temp\sgr.tar.gz):

  <target name="myTarget" description="Download application delivery file">
    <exec program="pscp.exe">
        <arg line="-batch -v -l ${ftp.user} -pw ${ftp.password} ${ftp.host}:${remote.dir}/${remote.file} D:\Temp\sgr.tar.gz"/>
    </exec>
  </target>

This target (with a space in target directory (D:\tmp 2\sgr.tar.gz)) is KO:

  <target name="myTarget" description="Download application delivery file">
    <exec program="pscp.exe">
        <arg line="-batch -v -l ${ftp.user} -pw ${ftp.password} ${ftp.host}:${remote.dir}/${remote.file} D:\Temp\tmp 2.tar.gz"/>
    </exec>
  </target>

I have this error:

[exec] More than one remote source not supported

I try with but is KO also.


Solution

  • Wrap the path to double-quotes (&quot):

        <arg line="-batch -v -l ${ftp.user} -pw ${ftp.password} ${ftp.host}:${remote.dir}/${remote.file} &quot;D:\Temp\tmp 2.tar.gz&quot;"/>
    

    See How to escape double quotes in XML attributes values?