curl --connect-timeout 判断国内外网络windows 批处理
1.下载编译curl
curl 下载地址:http://curl.haxx.se/download.html ,下载后解压到一个目录,使用vs开发者工具里的 “Visual Studio 命令提示(2010)” 打开命令行,
切换到源码目录 F:\curl-7.46.0\winbuild\,使用命令 nmake/f Makefile.vc mode=static 编译一下,在 F:\curl-7.46.0\builds\libcurl-vc-x86-release-static-ipv6-sspi-winssl\bin 目录下生成curl.exe 文件。
打开命令行切换到curl.exe目录,查看版本 curl -V
curl 7.46.0 (i386-pc-win32) libcurl/7.46.0 WinSSL WinIDN
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp
smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL
如果在使用curl时出现 curl: (1) Protocol https not supported or disabled in libcurl错误,首先检查一下用的curl.exe是否支持https协议.
2.知乎上有个根据curl --connect-timeout https://google.com 返回值判断是否是国内网络的代码段
链接地址:https://www.zhihu.com/question/30262900
# Guess your location, you know it.
location='oversea'
curl --connect-timeout 1 https://google.com 2>&1 >/dev/null
ret=$? if [ $ret -ne 0 ]; then
location='cn'
else
.......
这里翻译一个window下批处理版本
@echo off
set location='oversea'
echo '当前位置:%location%'
echo '访问http://www.baidu.com' rem -x 设置代理
rem --connect-timeout 连接超时1秒,命令正常执行结果为1指stdout标准输出,
rem 就是控制台输出;2指stderr错误输出,这里 >$1表示重定向到1,
rem 然后再重定向到null,linux下是/dev/null,windows下是nul。
curl -x "http://192.168.0.6:8080" --connect-timeout "http://www.baidu.com" >$>nul
rem errorlevel是个系统变量指上一条语句的执行结果,成功时等于0
echo '结果%errorlevel%' echo '访问https://google.com'
curl -x "http://192.168.0.6:8080" --connect-timeout "https://google.com" >$>nul
rem 这里是56,完整信息是 curl: () Proxy CONNECT aborted due to timeout
echo '结果%errorlevel%' IF not errorlevel then(
set location='CN'
)
echo '当前位置:%location%'
curl --connect-timeout 判断国内外网络windows 批处理的更多相关文章
- ConnectionString属性(网速慢的情况下研究Connect Timeout)
ConnectionString 类似于 OLE DB 连接字符串,但并不相同.与 OLE DB 或 ADO 不同,如果“Persist Security Info”值设置为 false(默认值),则 ...
- WINDOWS批处理命令使用大全
来源:http://www.942dn.com就是爱电脑网 WINDOWS批处理命令使用大全 批处理,也称为批处理脚本,英文译为BATCH,批处理文件后缀BAT就取的前三个字母.它的构成没有固定格式, ...
- ORA-12170: TNS:Connect timeout occurred
VM 作为ORACLE 服务器,客户端登陆提示超时,本地连接使用网络连接正常. D:>sqlplus system/oracle123@//192.168.63.121:15021/pdb01 ...
- [转帖]Windows批处理(cmd/bat)常用命令小结
Windows批处理(cmd/bat)常用命令小结 非常值得学习的文档 先放这里 有时间做实验, 转载自:“趣IT”微信公共号 前言 批处理文件(batch file)包含一系列 DOS命令,通常用于 ...
- Windows 批处理大全(附各种实例)
Windows 批处理大全(附各种实例) 2009年07月19日 21:31:00 阅读数:2552 批处理文件是无格式的文本文件,它包含一条或多条命令.它的文件扩展名为 .bat 或 .cmd.在命 ...
- Windows 批处理(cmd/bat)常用命令教程
Windows批处理(cmd/bat)常用命令教程 简单详细,建议收藏 常见问题: 1.如果你自己编写的.bat文件,双击打开,出现闪退 2.批处理.bat 文件中输出中文乱码 解决方法在文章末尾! ...
- Windows批处理(cmd/bat)常用命令
Windows批处理(cmd/bat)常用命令 一.总结 一句话总结: 1.批量处理图片的方式? PS批处理是基于强大的图片编辑软件Photoshop的,用来批量处理图片的脚本: 2.大量的重复的操作 ...
- Linux shell脚本判断服务器网络是否可以上网
Linux shell脚本判断网络畅通 介绍 在编写shell脚本时,有的功能需要确保服务器网络是可以上网才可以往下执行,那么此时就需要有个函数来判断服务器网络状态 我们可以通过curl来访问 www ...
- 常用的Windows批处理
切换执行路径 如果不换盘的话:cd xxx换盘:cd /d xxx 获取当前日期 编写Windows批处理时经常会需要使用到日期和时间作为文件名,所以是非常重要的. 如何获取日期呢?格式: ...
随机推荐
- Codeforces Round #342 (Div. 2)-A. Guest From the Past
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Android 跑马灯
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- Install Ansible on Mac OSX
from: https://devopsu.com/guides/ansible-mac-osx.html and : https://devopsu.com/guides/ansible-post- ...
- XSS常用技巧
一般发现一个xss漏洞后要做的基本上就是这些: 1. 伪造请求 使用$_REQUEST或$_GET 首先我们要找找该网站使用的程序是不是在网上能找到源码,如果能找到源码的话,就去分析后台管理员更改密码 ...
- 微信小程序-视图容器组件
view 视图容器 例如: <view class="section"> <view class="section__title">fl ...
- MyEclipse中的SVN操作手册
原文出处:http://blog.sina.com.cn/s/blog_8a3d83320100zhmp.html 1.导入项目 点击工具栏上的[File-Import],进入下图 (如果你的对话框中 ...
- App开发(Android与php接口)之:短信验证码
最近和同学们一起开发一个自主项目,要用到短信验证码,在网上搜索了很久,看到一个推荐贴,提到了很多不错的短信服务商.经过测试,帖子中提到的服务商他们的短信到达率和到达速度也都不错.最后,由于经费问题,我 ...
- java简单计算器
写的一个小计算器,留着以后看吧. import java.awt.BorderLayout; import java.awt.Button; import java.awt.Color; import ...
- mysql表创建好后添加外键
命令:alter table 需加外键的表 add constraint 外键名 foreign key(需加外键表的字段名) referencnes 关联表名(关联字段名); 注意:外键名不能重复
- Java里面获取当前服务器的IP地址
public static void main(String[] args) { try { InetAddress address = InetAddress.getLocalHost();//获取 ...