Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gradle ant.scp无法从远程服务器复制到本地目标不支持的远程服务器_Gradle_Groovy_Ant_Scp - Fatal编程技术网

Gradle ant.scp无法从远程服务器复制到本地目标不支持的远程服务器

Gradle ant.scp无法从远程服务器复制到本地目标不支持的远程服务器,gradle,groovy,ant,scp,Gradle,Groovy,Ant,Scp,我使用gradle将文件从远程机器复制到本地机器。下面是代码片段 ant.scp(file: "${userName}:${pwd}@${hostName}:${remoteFileAbsPath}", todir: localFileDirPath, trust: "true") 上面的代码片段在windows shell中运行良好,但在ubuntu shell中失败,错误如下 Caused by: : Copying from a remote server to a remote

我使用gradle将文件从远程机器复制到本地机器。下面是代码片段

    ant.scp(file: "${userName}:${pwd}@${hostName}:${remoteFileAbsPath}", todir: localFileDirPath, trust: "true")
上面的代码片段在windows shell中运行良好,但在ubuntu shell中失败,错误如下

Caused by: : Copying from a remote server to a remote server is not supported.
at org.apache.tools.ant.taskdefs.optional.ssh.Scp.execute(Scp.java:229)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:77)...
终端的常规scp工作正常。只有ant.scp只在linux环境中失败。taskdef声明是ant.taskdefname:'scp',classname:'org.apache.tools.ant.taskdefs.optional.ssh.scp',classpath:somepath。任何指向问题原因的指针/参考都将非常有用

在调试时,我刚刚发现变量localFileDirPath有@symbol。例如,localDir名称是sample@localDirectory. 现在,我猜ant.scp假设sample@localDirectory是另一个远程服务器-因此错误消息完全有意义。当我使用另一个不带@的localFileDirPath进行测试时,ant.scp工作正常。现在,在我的情况下,本地目录将有@。因此,我正在研究如何转义这个字符。

根据,当路径中有@characters时,使用localToDir而不是toDir:

  ant.scp(file: "${userName}:${pwd}@${hostName}:${remoteFileAbsPath}", localtodir: localFileDirPath, trust: "true")
使用localToDir,您不需要转义@字符,只需按原样发送即可