且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Ant SCP 任务中转义@

更新时间:2022-05-13 10:34:08

我在 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?