curl常用操作集锦
来源:互联网 发布:linux 字符串连接 编辑:程序博客网 时间:2024/05/22 13:48
一、帮助信息
#rpm -qa|grep curl
curl-7.15.5-15.el5
curl-devel-7.15.5-15.el5
确认已经安装了curl和curl-devel。
#man curl
相信你想要的东西都有,包括功能、参数、用法等。
二、常用参数
-s:静默模式,不会输出过程数据。
-o:输出到哪个文件或者设备,如果不想保存输出数据可以指定/dev/null。
-w:指定输出格式,输出内容是一个字符串,字符串中可以有变量或换行符、制表符等,变量用%{}包起来。
--data-binary:用于post发送二进制body,@xxx.bin
三、常用变量
http_code:response状态码,比如:200。
time_total:整个操作完成的总时间,单位秒。
time_namelookup:域名解析时间,单位秒。
time_connect:连接远程主机时间,单位秒。
time_pretransfer:发送数据前的时间,单位秒。
time_redirect:所有重定向操作的总时间,单位秒。
time_starttransfer:准备发送数据到收到服务器返回的第一个字节所用的时间,单位秒。
四、常用操作
1、监控网页的响应时间
#curl -o /dev/null -s -w "time_connect: %{time_connect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" "http://www.baidu.com"
#curl 'www.xxx.com:8080/bid' --data-binary @xxx.bin -w "result:%{time_namelookup}\t %{time_connect}\t %{time_pretransfer}\t %{time_redirect}\t %{time_starttransfer}\t %{time_total}\n" -o /dev/null -s
2、监控站点可用性
#curl -o /dev/null -s -w '%{http_code}\n' "http://www.taobao.com"
#rpm -qa|grep curl
curl-7.15.5-15.el5
curl-devel-7.15.5-15.el5
确认已经安装了curl和curl-devel。
#man curl
相信你想要的东西都有,包括功能、参数、用法等。
二、常用参数
-s:静默模式,不会输出过程数据。
-o:输出到哪个文件或者设备,如果不想保存输出数据可以指定/dev/null。
-w:指定输出格式,输出内容是一个字符串,字符串中可以有变量或换行符、制表符等,变量用%{}包起来。
--data-binary:用于post发送二进制body,@xxx.bin
三、常用变量
http_code:response状态码,比如:200。
time_total:整个操作完成的总时间,单位秒。
time_namelookup:域名解析时间,单位秒。
time_connect:连接远程主机时间,单位秒。
time_pretransfer:发送数据前的时间,单位秒。
time_redirect:所有重定向操作的总时间,单位秒。
time_starttransfer:准备发送数据到收到服务器返回的第一个字节所用的时间,单位秒。
四、常用操作
1、监控网页的响应时间
#curl -o /dev/null -s -w "time_connect: %{time_connect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" "http://www.baidu.com"
#curl 'www.xxx.com:8080/bid' --data-binary @xxx.bin -w "result:%{time_namelookup}\t %{time_connect}\t %{time_pretransfer}\t %{time_redirect}\t %{time_starttransfer}\t %{time_total}\n" -o /dev/null -s
2、监控站点可用性
#curl -o /dev/null -s -w '%{http_code}\n' "http://www.taobao.com"
0 0
- curl常用操作集锦
- curl常用操作
- asp常用操作集锦
- Linux常用操作集锦
- git 常用操作集锦
- linux git 常用操作集锦
- curl 问题集锦
- Openoffice.org calc常用操作函数集锦
- PHP常用的文件操作函数集锦
- PHP常用的文件操作函数集锦
- Openoffice.org calc常用操作函数集锦
- C# 不常用的字符串操作集锦
- PHP常用的文件操作函数集锦
- PHP常用的文件操作函数集锦
- PHP常用的文件操作函数集锦
- Eclipse常用操作及配置集锦
- PHP常用的文件操作函数集锦
- PHP常用的文件操作函数集锦
- 15.7 擦除的神秘之处
- 静谧、雅致时的你,是一页传奇的诗行
- phpcmsv9后台登录部分
- Ubuntu下编译基于libpoco工程详解
- MySQL学习笔记之三 表类型
- curl常用操作集锦
- Java实现仿百度文库文档在线阅读
- Swift中文教程(二)基本运算符
- How to add two multidimensional array in ruby
- 阿里巴巴、亚马逊线上开战 紧盯马来西亚商场
- Java Thread join() 的用法
- Swift中文教程(三) 字符串和字符
- ThinkPHP的controller里变量输出位置不正确导致变量输出无效,原因不明??
- 掩模的概念