简体   繁体   English

在wget bash命令中转义

[英]Escaping in wget bash command

wget -q -T 60 --retry-connrefused -t 5 --waitretry=60 --user=ftp2.company.com|company2013 --password=!company2013 -N -P data/parser/company/ ftp://ftp2.company.com/Production/somedata.zip

I'm having trouble with this command, because the password contains an exclamation mark. 我在使用此命令时遇到问题,因为密码包含感叹号。 I tried escaping with \\, tried single quotes, and it either gives the output: 我尝试用\\来转义,尝试使用单引号,然后输出:

wget: missing URL

or 要么

bash: !company2013: event not found

This is really demotivating... 这真是令人失望......

Perhaps this part needs to be quoted to prevent it from being seen as a pipe to another command. 也许这部分需要引用以防止它被视为另一个命令的管道。

--user='ftp2.company.com|company2013'

And this one too to prevent history expansion with !: 这也是为了防止历史扩张!:

--password='!company2013'

Final: 最后:

wget -q -T 60 --retry-connrefused -t 5 --waitretry=60 --user='ftp2.company.com|company2013' --password='!company2013' -N -P data/parser/company/ ftp://ftp2.company.com/Production/somedata.zip

And it's also a good idea to quote the other parts if on later time they have spaces: 如果稍后他们有空格,引用其他部分也是一个好主意:

wget -q -T 60 --retry-connrefused -t 5 --waitretry=60 --user='ftp2.company.com|company2013' --password='!company2013' -N -P "data/parser/company/" "ftp://ftp2.company.com/Production/somedata.zip"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM