Curl is a set of internet command line tools implemented using libcurl, and has very powerful functions. It supports many protocols, such as FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE, and LDAP. Currently, powerful explanatory languages such as php, perl, and python commonly used in O & M have built-in curl extensions. The script used in this article is very simple:
The code is as follows: |
Copy code |
#! /Bin/bash Usrl = ('www .111cn.net 'www .qq.111cn.net' 'www .a.com ') For I in $ {usrl [@]} Do Http_code = $ (curl-I-s $ I-w % {http_code }) Echo $ I status :$ {http_code: 9: 3} Done After the above script is run, the result is as follows: Www.111cn.net status: 200 Www.qq.111cn.net status: 200. Www.a.com status: 301 |
Note: Because www.a.com is a non-existent domain name, because I use a telecommunications network, after a domain name error occurs, it returns a disgusting Telecom
114 navigation page. Therefore, the http status code 301 is returned!