santaclaus 发表于 2018-8-21 08:53:40

shell脚本批量telnet ip port

PORT=XXXXX  
count=0
  
for i in $(cat ip_list.dat)
  
do
  
((count++))
  
echo "count=$count"
  
# 关键代码,1s自动结束telnet
  
(sleep 1;) | telnet $i $PORT >> telnet_result.txt
  
done
  
# 根据结果判断出正常可以ping通的ip
  
cat telnet_result.txt | grep -B 1 \] | grep | awk '{print $3}' | cut -d '.' -f 1,2,3,4 > telnet_alive.txt
  
# 差集,得到ping不同的ip
  
cat ip_list.dat telnet_alive.txt | sort | uniq -u > telnet_die.txt


页: [1]
查看完整版本: shell脚本批量telnet ip port