Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Batch test host connectivity through curl and ping commands

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Batch test host connectivity

#! / bin/bashcat testsport | while read linedo curl-v-- connect-timeout 15$ line > / dev/null 2 > & 1 if [$?-eq 0]; then echo $line:ok else echo $line:fail fidone

two。 Batch test host connectivity ping IP

#! / bin/bash# filename: / tmp/mydir/target_ip.txtfor ips in `cat / tmp/mydir/target_ ip.txt`do result= `ping-w 2-c 3 ${ips} | grep packet | awk-F ""'{print $6}'| awk-F "%"'{print $1}'| awk-F''{print $1} '`if [$result-eq 0]; then echo "${ips}" is ok! " Else echo "${ips}" is not connected. " Fidone

3. Batch test host connectivity curl IP

#! / bin/bash# filename: / tmp/target_ip.txtfor ips in `cat / tmp/target_ ip.txt`do echo ${ips} curl-v-- connect-timeout 5 https://${ips} > > / tmp/curltest.txt 2 > & 1 sed-n'$p 'curltest.txtdone

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report