#######时钟
#!/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
???
转载于:https://blog.51cto.com/12107647/1883168