shell脚本批量ping和ssh测试一批服务器ip是否可以连通

编程入门 行业动态 更新时间:2024-10-26 06:34:40

shell脚本<a href=https://www.elefans.com/category/jswz/34/1770428.html style=批量ping和ssh测试一批服务器ip是否可以连通"/>

shell脚本批量ping和ssh测试一批服务器ip是否可以连通

1、ping脚本
# cat ping.sh 
#!/bin/bash
for ip in `cat list`;
doif ping -c1 -w1 ${ip} &>/dev/null;thenecho "${ip}:yes ping"elseecho "${ip}:no ping"fi
done
2、list文件存放服务器ip
# cat list
10.186.186.101
10.186.186.1023、执行ping.sh脚本,测试list文件ip列表是否可以ping通
# sh ping.sh 
10.186.186.101:yes ping
10.186.186.102:no ping
1、ssh脚本
# cat ssh.sh
#!/bin/bash
for i in `cat list` ; dossh -o ConnectTimeout=3  $i >/dev/null 2>&1if [ $? -eq 0 ];thenecho "$i:yes ssh";exitelseecho "$i:no ssh"fi
done

更多推荐

shell脚本批量ping和ssh测试一批服务器ip是否可以连通

本文发布于:2023-07-28 21:52:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329639.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:批量   脚本   服务器   测试   shell

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!