通过变量将参数传递给wget

时间:2017-07-21 07:15:47

标签: bash variables special-characters quotes

当按照以下命令运行时,我遇到了wget乱码的参数问题。我也包括了结果。它基本上开始将输入作为URL&#39>

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.

任何想法? 谢谢

0 个答案:

没有答案