1 获取返回码:(only)
[[email protected] zabbix_agentd.conf.d]# curl -s --connect-timeout 20 -w "%{http_code}" -o /dev/null www.baidu.com
200[[email protected] 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的进度输出
[[email protected] scripts]# curl -s -I 192.168.100.13:80 --connect-timeout 2 | sed -n ‘1p‘ HTTP/1.1 200 OK [[email protected] 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
时间: 2024-11-03 23:26:59