-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpect-Basic.exp
More file actions
39 lines (34 loc) · 849 Bytes
/
Expect-Basic.exp
File metadata and controls
39 lines (34 loc) · 849 Bytes
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
37
38
#!/usr/bin/expect
set user "userid";
set pass "mypassword";
set ipaddr1 "1.1.1.1";
set ipaddr2 "2.2.2.2";
set outfile "expecttest.outfile";
exp_log_file -a $outfile;
log_user 1;
spawn /usr/bin/ssh -o StrictHostKeyChecking=no $user@$ipaddr1;
expect "*assword: ";
send "$pass\r";
expect {
"*> " { puts "old code"; send "enable\r"; send "$pass\r"; }
"*# " { send "\r" ; }
#eof { }
#timeout { puts "timeout waiting for response" ; close ; exit }
}
expect "*#";
send "show hostname\r";
expect "*#";
send eof;
spawn /usr/bin/ssh -o StrictHostKeyChecking=no $user@$ipaddr2;
expect "*assword: ";
send "$pass\r";
expect {
"*> " { send "enable\r"; send "$pass\r"; }
"*# " { send "\r"; }
#eof { }
#timeout { puts "timeout waiting for response" ; close ; exit }
}
expect "*#";
send "show hostname\r";
expect "*#";
send eof;