Curl перестраивает URL при указании нескольких запусков в одной команде - PullRequest
0 голосов
/ 22 января 2019

Я пытаюсь выполнить команду curl 5 раз, как в примере ниже, и получаю ошибки.Кто-нибудь может пролить свет на то, что я делаю неправильно.

Команда:

curl http://google.com {1..5} -v

Вывод:

* Rebuilt URL to: http://google.com/
*   Trying 172.217.164.110...
* TCP_NODELAY set
* Connected to google.com (172.217.164.110) port 80 (#0)
> GET / HTTP/1.1
> Host: google.com
> User-Agent: curl/7.52.1
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Location: http://www.google.com/
< Content-Type: text/html; charset=UTF-8
< Date: Tue, 22 Jan 2019 19:57:19 GMT
< Expires: Thu, 21 Feb 2019 19:57:19 GMT
< Cache-Control: public, max-age=2592000
< Server: gws
< Content-Length: 219
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< 
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
* Curl_http_done: called premature == 0
* Connection #0 to host google.com left intact
* Rebuilt URL to: 1/
*   Trying 0.0.0.1...
* TCP_NODELAY set
* Immediate connect fail for 0.0.0.1: No route to host
* Closing connection 1
curl: (7) Couldn't connect to server
* Rebuilt URL to: 2/
*   Trying 0.0.0.2...
* TCP_NODELAY set
* Immediate connect fail for 0.0.0.2: No route to host
* Closing connection 2
curl: (7) Couldn't connect to server
* Rebuilt URL to: 3/
*   Trying 0.0.0.3...
* TCP_NODELAY set
* Immediate connect fail for 0.0.0.3: No route to host
* Closing connection 3
curl: (7) Couldn't connect to server
* Rebuilt URL to: 4/
*   Trying 0.0.0.4...
* TCP_NODELAY set
* Immediate connect fail for 0.0.0.4: No route to host
* Closing connection 4
curl: (7) Couldn't connect to server
* Rebuilt URL to: 5/
*   Trying 0.0.0.5...
* TCP_NODELAY set
* Immediate connect fail for 0.0.0.5: No route to host
* Closing connection 5
curl: (7) Couldn't connect to server

1 Ответ

0 голосов
/ 22 января 2019

Команда curl http://google.com {1..5} -v не скажет curl сделать 5 запросов на ваш URL.

Результат этой команды:

curl http://google.com 1 2 3 4 5 -v

Первоначальный запрос работает, но следующие 5 являются недействительными URL.

Вы либо ищете:

curl http://google.com http://google.com http://google.com http://google.com http://google.com

или цикл bash:

for i in `seq 1 5` ; do
    curl http://google.com -v
done
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...