1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/usr/bin/expect
# 检查参数数量
if {$argc < 1} {
puts "Usage: $argv0 <target_host>"
exit 1
}
set target_host [lindex $argv 0]
spawn ssh "$target_host"
expect {
"yes/no" {
send "yes\r"
exp_continue
}
}
while {1} {
expect {
"Press" {
send "\n"
exp_continue
}
"y/N" {
send "\n"
exp_continue
}
"root" {
break;
}
}
}
interact
|