码迷,mamicode.com
首页 > 系统相关 > 详细

shell script

时间:2021-06-02 20:19:59      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:log   class   gre   color   oca   clock   who   txt   read   

 

 

#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

 

shell script

标签:log   class   gre   color   oca   clock   who   txt   read   

原文地址:https://www.cnblogs.com/samwang10/p/14838388.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!