如何逃脱@ Ant中SCP任务 [英] How to escape @ in Ant SCP task

查看:355
本文介绍了如何逃脱@ Ant中SCP任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想请教您一些帮助。我如何使用SCP任务时,我的用户名包含一个@符号?

I would like to ask you for some help. How can I use an scp task when my username contains an @ sign?

我试图逃跑,在许多方面的字符,但它不工作。在下面的例子中,我的用户名是user@host.com

I tried to escape the character in many ways but it isn't working. In the following example, my username is user@host.com

<scp file="test.txt" todir="&quot;user@host.com&quot;:password@ftp.host.com:/" trust="true" sftp="true"/>
<scp file="test.txt" todir="'user@host.com':password@ftp.host.com:/" trust="true" sftp="true"/>
<scp file="test.txt" todir="user\@host.com:password@ftp.host.com:/" trust="true" sftp="true"/>

但输出始终是相同的:

But the output is always the same:

neither password nor keyfile for user "user has been given.  Can't authenticate. 

请,反正是有强制任务正确地解析这个字符串?非常感谢你。

Please, is there anyway to force the task to parse this string correctly? Thank you very much.

顺便说一句,我不知道为什么,但我目前的供应商是不可能不附加主机名来创建一个用户名。

By the way, I don't know why but with my current provider it is impossible to create a username without appending the hostname.

推荐答案

我使用SCP的任务在我的build.xml,它的形式是这样的:

I use the SCP task in my build.xml and it's form looks like this:

<scp file="package/ROOT.war" todir="user@example.com:~" trust="true" password="${password}"/>

纵观<一个href=\"http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java?view=markup\"相对=nofollow>的SCP任务源的在函数 parseUri(字符串URI)(行370)看来该任务可以支持用户名一个@符号。这些限制似乎与具有路径:或@在其中通过此评论所看到:

Looking at the source of the SCP Task at the function parseUri(String uri) (line 370) it appears that the task can support a username with a @ symbol. The restrictions appear to be with paths that have a : or @ in them as seen by this comment:

// user:password@host:/path notation
// everything upto the last @ before the last : is considered
// password. (so if the path contains an @ and a : it will not work)

在code似乎并不支持这种意见(如指出,
马丁克莱顿)。你也可以看到你是指它的密码或密钥文件丢失时触发的错误。也许一个密码组合中的用户名:密码@主机:/路径符号,并用@用户名导致的问题。

The code doesn't seem to support this comment (as pointed out by martin clayton). You can also see the error you are referring which is triggered when the password or the keyfile is missing. Maybe the combination of a password in user:password@host:/path notation and a username with an @ is causing problems?

这篇关于如何逃脱@ Ant中SCP任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆