Curl--connect-timeout Judging the network Windows batch processing at home and abroad

Source: Internet
Author: User

1. Download the compiled Curl

curl:http://curl.haxx.se/download.html, download and unzip to a directory, use the "Visual Studio Command Prompt (2010)" In the VS developer tool to open the command line,

Switch to source directory F:\curl-7.46.0\winbuild\, use the command nmake/f MAKEFILE.VC mode=static compile, in F:\curl-7.46.0\builds\ Generate the Curl.exe file under the Libcurl-vc-x86-release-static-ipv6-sspi-winssl\bin directory.

Open the command line switch to the Curl.exe directory to view version 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

If curl appears when using curl: (1) Protocol HTTPS not supported or disabled in Libcurl error, first check whether the Curl.exe supported HTTPS protocol.

2. There is a code snippet based on Curl--connect-timeout https://google.com return value to determine if it is a domestic network

Link Address: 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

.......

Here to translate a window under batch processing version

@echo Offset location='oversea'Echo 'Current Location:%location%'Echo 'Visit http://www.baidu.com'REM-x Set agent REM--connect-timeout1The connection timed out 1 seconds, the command normal execution result is 1 refers to the STDOUT standard output, the REM is the console output, 2 refers to the stderr error output, here2>$ = Redirect to 1,rem and then redirect to Null,linux is/dev/NULL, under Windows is nul. Curl-X"http://192.168.0.6:8080"--connect-timeout1 "http://www.baidu.com" 2>$1>nulrem ERRORLEVEL is a system variable that refers to the execution result of the previous statement, which equals 0 on successEcho 'result%errorlevel%'Echo 'Visit https://google.com'Curl-X"http://192.168.0.6:8080"--connect-timeout1 "https://google.com" 2>$1>Nulrem Here is 56, the complete message is curl: ( About) Proxy CONNECT aborted due to timeoutEcho 'result%errorlevel%'IF not errorlevel0  Then(Set location='CN')   Echo 'Current Location:%location%'    

Curl--connect-timeout Judging the network Windows batch processing at home and abroad

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.