curl 命令常用

1 获取返回码:(only)

[root@master zabbix_agentd.conf.d]# curl -s --connect-timeout 20 -w "%{http_code}"  -o /dev/null www.baidu.com
200[root@master zabbix_agentd.conf.d]#


参数详解

curl 

-s  -s/--silent

              Silent or quiet mode. Don't show progress meter or error messages.  Makes Curl mute.

-I

-w   -w/--write-out <format> 。 variables are specified as %{variable_name}

-o -o/--output <file>




2 返回头部信息

curl -I 
http://www.baidu.com




3 -s 的效果

查看有没有-s的效果: 你可以看到那些curl的进度输出

[root@master scripts]# curl -s -I 192.168.100.13:80 --connect-timeout 2 | sed -n '1p' 
HTTP/1.1 200 OK
[root@master scripts]# curl  -I 192.168.100.13:80 --connect-timeout 2 | sed -n '1p'   
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   612    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
HTTP/1.1 200 OK





你可能感兴趣的:(curl,命令常用)