Shell practice: ping the DNS for batch resolution of domain names

Source: Internet
Author: User
Shell practice: ping the DNS01 for batch resolution of domain names and ping the DNS02 requirement for batch resolution of domain names: Read the domain name list from a file: 031 read the domain name list file. 04 the format of the list file is 051cn062cn072. the resolved ip address is output to a file. 08 output file shell practice: ping the DNS for batch resolution of domain names
01 requirement for batch domain name resolution by ping DNS02: Read the domain name list from a file: 031. Read the domain name list file. 04 the format of the list file is 051. cn062.cn072. output the resolved ip address to a file. 08. the output file format is 09DNS: 1.cn 1.1.1.110DNS: 2.cn 2.2.2.211 #! /Bin/sh12 # code by scpman13 # write 2013-08-2214 # ping test15echo> pingok.txt 16 echo> pingfaild.txt 17 # read ip list18for ip in 'cat ip.txt '19do20 # ping one21res = 'ping-c 1 $ ip | egrep "\(. * \) "| sed-e" s/PING/DNS:/g; s/(// g; s /): 56 data bytes // g "'22if ['echo" $ res "| grep-c 'dn''-gt 0] 23then24 echo $ res25 echo $ res> pingok.txt 26else27 echo ping $ ip fail28 echo $ ip> pingfaild.txt 29fi 30done31 save Row: 32 # sh. sh33DNS: www.expo-china.com 222.73.238.5134DNS: page.china.alibaba.com 110.75.195.1035DNS: g0183.61.117.10336ping: cannot resolve www. d1net. comexpo: Unknown host37ping www. d1net. comexpo fail38DNS: www.youxiuhui.com 219.234.4.9039 final result: 40 successful 41 # cat pingok.txt 42DNS: www.expo-china.com success: page.china.alibaba.com 110.75.195.1044DNS: expo. asi Apump.cn 222.73.57.5245... 46 # cat pingfaild.txt 47www. d1net. comexpo48www. cecsz. net1
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.