如何在 Ant SCP 任务中转义@ [英] How to escape @ in Ant SCP task

查看:66
本文介绍了如何在 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"/>

但输出总是相同的:

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.

推荐答案

我在 build.xml 中使用了 SCP 任务,它的形式如下所示:

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}"/>

查看函数parseUri(String uri)(第370行)中SCP任务的来源似乎该任务可以支持用户名@ 符号.限制似乎与路径中包含 : 或 @ 的路径有关,如该评论所示:

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)

代码似乎不支持此注释(如马丁克莱顿).您还可以看到您所指的错误,该错误在密码或密钥文件丢失时触发.也许 user:password@host:/path 符号中的密码和带有 @ 的用户名的组合会导致问题?

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天全站免登陆