shell script

时间:2021-06-02 20:19:59   收藏:0   阅读:0

 

 

#ping whole local domain
for
ip in {1..255};do ping -c 3 192.168.110.$ip >> ping.log;done grep 3 ttl ping.log |awk {print $4} | sed s\:\\g |while read ip;do echo $ip >> ips.txt;done cat ips.txt|while read ip;do ssh $ip ;done

 

 

#get correct password from pwd array
while
IFS= read -r ip do echo "testing $ip" >> result.txt while IFS= read -r pwd do timeout 1s sshpass -p $pwd ssh $ip "exit" && echo -e "$ip \t $pwd" >> /root/result.txt && break done<pwds done<ips

 

 

#excute command on remote
function
SyncTime() { sshpass -p $2 ssh -tt $1 << EOF date -s "`date`" hwclock -w exit 0 EOF } while IFS= read -r line do ip=`echo $line | awk -F {print $1}` pw=`echo $line | awk -F {print $2}` SyncTime $ip $pw done<pwds.txt exit 0

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!