ojh*_*ins 6 windows logging curl cmd
是否可以将cURL的输出定向到文件中?
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1354 100 1354 0 0 17358 0 --:--:-- --:--:-- --:--:-- 17358
100 67081 100 67081 0 0 68171 0 --:--:-- --:--:-- --:--:-- 4031k
Run Code Online (Sandbox Code Playgroud)
我找不到任何--help可以表明你可以的东西.-o刚刚完成了我能说的回应.
我只是想知道请求是否成功以及需要多长时间.
MC *_* ND 14
此输出将发送到stderr.因此,要获得它所需要的只是将流2(stderr)重定向到文件
curl -o responseFile.html http://www.somewhere.com 2> informationFile.txt
Run Code Online (Sandbox Code Playgroud)
但是,正如您的捕获显示的那样,时间并不总是包含在内.
知道请求是否成功以及花费多长时间的更好选择是让curl输出一些内部变量.这是通过-w开关完成的.所以,你的命令看起来应该如此
curl -o responseFile.html http://www.somewhere.com -w "%{response_code};%{time_total}" > dataFile.txt 2> informationFile.txt
Run Code Online (Sandbox Code Playgroud)
这样,响应将转到responseFile.html(或任何你需要的),进度信息(stderr或流2)将转到informationFile.txt,所需的请求响应代码和时间信息将转到dataFile.txt
这是你需要的:
curl -o gettext.html http://www.gnu.org/software/gettext/manual/gettext.html 2> details.txt
Run Code Online (Sandbox Code Playgroud)
以上将保存 urlgettext.html和 curl 详细信息到details.txt.
| 归档时间: |
|
| 查看次数: |
20065 次 |
| 最近记录: |