###### #时钟
#!/bin/bash
Min=1
Hour=1
for ((sec=5; sec>=0; sec--))
Do
Echo-ne "${hour}:${min}:${sec}s End"
Sleep 1
Echo-ne "\ r \ r"
While ["$SEC"-le "0"-a "$MIN"-ge "0"]
Do
Echo-ne "${hour}:${min}:${sec}s End"
Echo-ne "\ r \ r"
((min--))
Sec=60
While ["$MIN"-lt "0"-a "$HOUR"-GT "0"]
Do
Echo-ne "${hour}:${min}:${sec}s End"
Echo-ne "\ r \ r"
((hour--))
min=59
Done
Done
While ["$SEC" = "0"-a "$MIN" = "0"-a "$HOUR" = "0"]
Do
echo "Time is up!! ........."
Break
Done
Done
[Email protected] shell]# sh clock1.sh
1:0:48s after the end of ^c
2. Test whether the host is turned on and set up the user
[[email protected] 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 [email protected] $IP $COMM
Expect {
&nbs p; "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
???
Shell, not successful