Example of http status detection in linux

Source: Internet
Author: User
Tags curl

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!

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.