Escaping in wget bash command

孤者浪人 提交于 2019-12-10 19:43:02

问题


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...


回答1:


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"


来源:https://stackoverflow.com/questions/18120626/escaping-in-wget-bash-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!