Get the App
SLTechnology News&Howtos  ›  Servers  › 

Batch test host connectivity through curl and ping commands

Shulou Source: shulou.com Published: 2022-06-02 23:11:39 11月15日 Update

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

Tags: Host test command Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi Microsoft Redmi Shulou Technology