shell,時鐘

#######時鐘
#!/bin/bash
MIN=1
HOUR=1
for ((SEC=5;SEC>=0;SEC--))
do
  echo -ne "${HOUR}:${MIN}:${SEC}s 後結束"
  sleep 1
  echo -ne "\r  \r"

   while [ "$SEC" -le "0" -a "$MIN" -ge "0" ]
   do
          echo -ne "${HOUR}:${MIN}:${SEC}s 後結束"
          echo -ne "\r  \r"
          ((MIN--))
          SEC=60
    while [ "$MIN" -lt "0" -a "$HOUR" -gt "0" ]
    do

     echo -ne "${HOUR}:${MIN}:${SEC}s 後結束"
     echo -ne "\r  \r"
     ((HOUR--))
     MIN=59
    done
   done
 while [ "$SEC" = "0" -a "$MIN" = "0" -a "$HOUR" = "0" ]
 do
  echo  "時間已到!!........."
 break
 done
done

[root@shell shell]# sh clock1.sh
1:0:48s 後結束^C

2.測試主機是否開啓,並建立用戶

[root@shell mnt]# vim ssh.exp
#!/usr/bin/expect
set timeout 3
set IP [lindex $argv 0]
set PASS [lindex $argv 1]
set COMM [lindex $argv 2]
spawn ssh root@$IP $COMM
expect {
        "yes/no"
        {send "yes/r";exp_continue}
        "password:"
        {send "$PASS\r"}
        }
expect eof
spawn /root/Desktop/shell/ask.sh
        expect "name:"
        send "liu\r"
        expect "old"
        send "17\r"
        expect "class"
        send "8\r"
expect eof

#!/bin/bash
for NUM in {15..20}
do
ping -c1 -w1 172.25.254.$NUM &> /dev/null && (
        /mnt/ssh.exp 172.25.254.$NUM redhat hostname | grep -E "The|ECDSA|connecting|Warning|password|spawn" -v|sed "s/Permission\ denied\,\ please\ try\ again\./172.25.254.$NUM password is error/g"
)
done
???

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章