curl_cmd curl命令整理 小技巧
2016-04-02 15:33
656 查看
curl官网:
ref:https://curl.haxx.se/docs/manpage.html
常用的字符界面web 客户端
elinks --dump
curl -so /dev/null -w "%{time_total},%{time_namelookup},%{time_connect},%{time_pretransfer},%{time_redirect},%{time_starttransfer}\n" http://172.16.5.80:9081/ROOT/login.jsp
wget --http-user=admin --http-passwd=admin http://172.16.5.137:8161/admin/queues.jsp
curl获取状态码
curl -I -m 10 -o /dev/null -s -w %{http_code} news.ehomepay.com.cn
-I获取头文件
curl --connect-timeout 20 -m 20 -o /dev/null -s -w %{http_code} http://172.26.113.194/
--connect-timeout 20 最大连接时间 20s ,如果连接上后,时间不在计算
-m 20 最大执行时间 20秒 ,总共的连接时不能超过20秒
-o /dev/null 输出信息不显示
-s 安静输出模式
-w %{http_code} 只输出状态码
curl下载
curl --silent http://172.16.4.250/tools/ae_scan_linux.sh -o scan.sh
curl指定用户密码
curl -u username:pass http://www.xxx.com
curl -u read:passwd ftp://10.12.1.101
#curl通过 "@"参数进行上传文件 curl上传文件
curl --header "Content-Type: text/xml" --data-binary @$OUTPUTFILE "$protocol://$hostName:$portNo/discoveryServlet/WsDiscoveryServlet?COMPUTERNAME=$COMPUTERNAME"
#wget 通过--post-file进行上传文件
wget "$protocol://$hostName:$portNo/discoveryServlet/WsDiscoveryServlet?COMPUTERNAME=$COMPUTERNAME" --post-file=./$COMPUTERNAME.xml --header="Content-Type:text/xml" > /dev/null 2>&1
culr post 请求
注意& 是分隔符
特殊字符 需要转义 \
-d 接 post 参数
#curl http://172.16.4.134/sql_insert.php -d "user=user01&password=123123&ip=172.16.15.17&datetime=2014-09-30 16:53:00&system_load=22.31"
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<body>
172.16.15.17 2014-09-30 16:53:00 22.31 xixi</body>
</head>
</html>
culr post 请求
curl -d 'userName=13141026305&userPwd=1U8JkB4USEpzmTjbZfq\/CQ\=\=&ck=744336c7F0c8a4c0D386246990c37b51' http://10.35.13.103:8080/ROOT/login
curl重启comm 定期重启comm
curl -d "patch_number=common&system=new_online_restart" ttp://172.16.4.134/update_ol/do_ol_publish.php
curl_QA
##################################################
curl访问web服务状态码为000
1.如果是有时候返回200,有时候返回000,原因可能是超时时间设置的太短了,导致超时,所以返回状态码为000
解决方式:
就是延长超时时间-m 50 。
curl -k -I -m 50 -o /dev/null -s -w "%{http_code} %{time_total}" https://www.ehomepay.com.cn
2.curl访问不信任的https
curl通过https访问内网服务器的时候,会出现不信任证书的情况,导致直接返回状态码为000,解决方式添加:
-k/--insecure
(SSL) This option explicitly allows curl to perform "insecure" SSL connections and transfers. All
SSL connections are attempted to be made secure by using the CA certificate bundle installed by
default. This makes all connections considered "insecure" to fail unless -k/--insecure is used.
If this option is used twice, the second time will again disable it.
curl -k -I -m 50 -o /dev/null -s -w "%{http_code} %{time_total}" https://10.12.8.21
##################################################
wget 下载https文件的时候需要添加 --no-check-certificate
但是此处下载还是报错。
[root@RNp-Git01 ~]# wget --no-check-certificate https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.7.tgz
--2015-11-13 13:03:23-- https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.7.tgz
Resolving fastdl.mongodb.org... 54.230.124.82, 54.230.124.117, 54.230.124.81, ...
Connecting to fastdl.mongodb.org|54.230.124.82|:443... connected.
OpenSSL: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
Unable to establish SSL connection.
解决方式
通过curl下载https,curl下载的时候提示不支持https,可以添加如下参数 https下载
curl -O -L https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.7.tgz
##################################################
此处是网上发现的,感觉很不错,特此推荐
#########################################################
设置curl的输出格式,输出标准化的日志格式
# cat curl-format.txt
\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
\n
# curl -w "@curl-format.txt" -o /dev/null -s https://www.ehomepay.com.cn
time_namelookup: 0.003
time_connect: 0.005
time_appconnect: 0.128
time_pretransfer: 0.128
time_redirect: 0.000
time_starttransfer: 1.950
----------
time_total: 1.960
ref:https://curl.haxx.se/docs/manpage.html
常用的字符界面web 客户端
elinks --dump
curl -so /dev/null -w "%{time_total},%{time_namelookup},%{time_connect},%{time_pretransfer},%{time_redirect},%{time_starttransfer}\n" http://172.16.5.80:9081/ROOT/login.jsp
wget --http-user=admin --http-passwd=admin http://172.16.5.137:8161/admin/queues.jsp
curl获取状态码
curl -I -m 10 -o /dev/null -s -w %{http_code} news.ehomepay.com.cn
-I获取头文件
curl --connect-timeout 20 -m 20 -o /dev/null -s -w %{http_code} http://172.26.113.194/
--connect-timeout 20 最大连接时间 20s ,如果连接上后,时间不在计算
-m 20 最大执行时间 20秒 ,总共的连接时不能超过20秒
-o /dev/null 输出信息不显示
-s 安静输出模式
-w %{http_code} 只输出状态码
curl下载
curl --silent http://172.16.4.250/tools/ae_scan_linux.sh -o scan.sh
curl指定用户密码
curl -u username:pass http://www.xxx.com
curl -u read:passwd ftp://10.12.1.101
#curl通过 "@"参数进行上传文件 curl上传文件
curl --header "Content-Type: text/xml" --data-binary @$OUTPUTFILE "$protocol://$hostName:$portNo/discoveryServlet/WsDiscoveryServlet?COMPUTERNAME=$COMPUTERNAME"
#wget 通过--post-file进行上传文件
wget "$protocol://$hostName:$portNo/discoveryServlet/WsDiscoveryServlet?COMPUTERNAME=$COMPUTERNAME" --post-file=./$COMPUTERNAME.xml --header="Content-Type:text/xml" > /dev/null 2>&1
culr post 请求
注意& 是分隔符
特殊字符 需要转义 \
-d 接 post 参数
#curl http://172.16.4.134/sql_insert.php -d "user=user01&password=123123&ip=172.16.15.17&datetime=2014-09-30 16:53:00&system_load=22.31"
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<body>
172.16.15.17 2014-09-30 16:53:00 22.31 xixi</body>
</head>
</html>
culr post 请求
curl -d 'userName=13141026305&userPwd=1U8JkB4USEpzmTjbZfq\/CQ\=\=&ck=744336c7F0c8a4c0D386246990c37b51' http://10.35.13.103:8080/ROOT/login
curl重启comm 定期重启comm
curl -d "patch_number=common&system=new_online_restart" ttp://172.16.4.134/update_ol/do_ol_publish.php
curl_QA
##################################################
curl访问web服务状态码为000
1.如果是有时候返回200,有时候返回000,原因可能是超时时间设置的太短了,导致超时,所以返回状态码为000
解决方式:
就是延长超时时间-m 50 。
curl -k -I -m 50 -o /dev/null -s -w "%{http_code} %{time_total}" https://www.ehomepay.com.cn
2.curl访问不信任的https
curl通过https访问内网服务器的时候,会出现不信任证书的情况,导致直接返回状态码为000,解决方式添加:
-k/--insecure
(SSL) This option explicitly allows curl to perform "insecure" SSL connections and transfers. All
SSL connections are attempted to be made secure by using the CA certificate bundle installed by
default. This makes all connections considered "insecure" to fail unless -k/--insecure is used.
If this option is used twice, the second time will again disable it.
curl -k -I -m 50 -o /dev/null -s -w "%{http_code} %{time_total}" https://10.12.8.21
##################################################
wget 下载https文件的时候需要添加 --no-check-certificate
但是此处下载还是报错。
[root@RNp-Git01 ~]# wget --no-check-certificate https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.7.tgz
--2015-11-13 13:03:23-- https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.7.tgz
Resolving fastdl.mongodb.org... 54.230.124.82, 54.230.124.117, 54.230.124.81, ...
Connecting to fastdl.mongodb.org|54.230.124.82|:443... connected.
OpenSSL: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
Unable to establish SSL connection.
解决方式
通过curl下载https,curl下载的时候提示不支持https,可以添加如下参数 https下载
curl -O -L https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.7.tgz
##################################################
此处是网上发现的,感觉很不错,特此推荐
#########################################################
设置curl的输出格式,输出标准化的日志格式
# cat curl-format.txt
\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
\n
# curl -w "@curl-format.txt" -o /dev/null -s https://www.ehomepay.com.cn
time_namelookup: 0.003
time_connect: 0.005
time_appconnect: 0.128
time_pretransfer: 0.128
time_redirect: 0.000
time_starttransfer: 1.950
----------
time_total: 1.960
相关文章推荐
- Hibernate主键生成策略
- 操作系统重要引论
- HD1142 穿越丛林
- 轮播图系列教程(五),左右切换,运动框架应用——和派孔明
- 上架被拒绝(个人总结)
- 在链接里使用thinkphp的U方法
- 大数乘法[JAVA实现]-经典笔试题
- HashMap 源码解析
- POJ1789 Truck History
- 面试题思考:Stack和Heap的区别
- linux基础之公共NTP服务器
- centos 7 安装JDK (Linux安装jdk)
- 排序算法
- centos 7 安装JDK (Linux安装jdk)
- Drupal 7.31 SQL注入漏洞利用具体解释及EXP
- 自定义Chrome插件Vimium
- 线段树题目总结
- [置顶] android开发之java JDK环境变量配置的信息代码 附详细教程。
- 1600 计算几何:数星星
- Linux中实现多网卡绑定总结