通过变量将参数传递给 WGET

passing parameters to wget via variable

提问人:Steven Lutz 提问时间:7/21/2017 最后编辑:Steven Lutz 更新时间:7/22/2017 访问量:578

问:

我一直遇到一个问题,即 wget 的参数在作为以下命令运行时变得混乱。我还包括了结果。它基本上开始将输入作为 URL 的

header='--header="User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:23.0) Gecko/20100101 Firefox/23.0" --header="Accept: image/png,image/*;q=0.8,*/*;q=0..5" --header="Accept-Encoding: gzip, deflate" --header="Referer: https://www.google.com/"'

wget -O- http://website.com $header | gzip -d
--2017-07-21 16:05:22--  http://google.com/
Resolving google.com (google.com)... 2607:f8b0:4000:80e::200e, 172.217.9.174
Connecting to google.com (google.com)|2607:f8b0:4000:80e::200e|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.google.com/ [following]
--2017-07-21 16:05:22--  http://www.google.com/
Resolving www.google.com (www.google.com)... 2607:f8b0:4007:804::2004, 172.217.11.68
Connecting to www.google.com (www.google.com)|2607:f8b0:4007:804::2004|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘STDOUT’

    [ <=>                                                                                                                                                                                      ] 11,606      --.-K/s   in 0.02s

2017-07-21 16:05:22 (491 KB/s) - written to stdout [11606]

--2017-07-21 16:05:22--  http://mozilla/5.0
Resolving mozilla (mozilla)... 104.239.207.44, 198.105.244.130
Connecting to mozilla (mozilla)|104.239.207.44|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 166 [text/html]
Saving to: ‘STDOUT’

100%[=========================================================================================================================================================================================>] 166         --.-K/s   in 0s

2017-07-21 16:05:23 (14.9 MB/s) - written to stdout [166/166]

--2017-07-21 16:05:23--  http://(windows/
Resolving (windows ((windows)... failed: Name or service not known.
wget: unable to resolve host address ‘(windows’
--2017-07-21 16:05:24--  http://nt/
Resolving nt (nt)... 198.105.254.130, 104.239.207.44
Reusing existing connection to mozilla:80.
HTTP request sent, awaiting response... 200 OK
Length: 166 [text/html]
Saving to: ‘STDOUT’

100%[=========================================================================================================================================================================================>] 166         --.-K/s   in 0s

2017-07-21 16:05:24 (16.5 MB/s) - written to stdout [166/166]

--2017-07-21 16:05:24--  http://5.1;/
Resolving 5.1; (5.1;)... failed: Name or service not known.
wget: unable to resolve host address ‘5.1;’
--2017-07-21 16:05:24--  ftp://rv/23.0)
           => ‘-’
Resolving rv (rv)... 104.239.207.44, 198.105.244.130
Connecting to rv (rv)|104.239.207.44|:21... failed: No route to host.
Connecting to rv (rv)|198.105.244.130|:21... failed: Connection timed out.
Retrying.

--2017-07-21 16:07:33--  ftp://rv/23.0)
  (try: 2) => ‘-’
Connecting to rv (rv)|104.239.207.44|:21... failed: No route to host.
Connecting to rv (rv)|198.105.244.130|:21... failed: Connection timed out.
Retrying.

有什么想法吗? 谢谢

bash 变量特殊 字符 引号

评论

0赞 melpomene 7/21/2017
变量中 bash 引号的可能重复,在扩展为命令时处理不同
0赞 melpomene 7/21/2017
stackoverflow.com/questions/16397264/......
0赞 Steven Lutz 7/21/2017
感谢您发布这些内容,但我仍然无法让它工作。
0赞 Lukas Isselbächer 7/21/2017
您能否提供错误消息或更具体地说明参数变得混乱?
0赞 Steven Lutz 7/22/2017
我已经更新了原来的帖子。

答: 暂无答案