-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcp.exp
44 lines (35 loc) · 811 Bytes
/
cp.exp
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
39
40
41
42
43
44
#!/usr/bin/expect -f
# Set variables
set hostip [lindex $argv 0]
set hostname [lindex $argv 1]
set username [lindex $argv 2]
set password [lindex $argv 3]
set enablepassword [lindex $argv 4]
set logfile [lindex $argv 5]
spawn ssh $username\@$hostip
expect {
timeout { send_user "\nTimeout Exceeded - Check Host\n"; exit 1 }
eof { send_user "\nSSH Connection To $hostname Failed\n"; exit 1 }
"*#" {}
"*assword:" {
send "$password\n"
}
}
log_user 0
log_file -noappend -a ${logfile}_clish.conf
send "clish -c \"show configuration\"\n"
expect {
"*]#" {}
}
log_file
send_user "\n${hostname} CLISH configuration saved\n"
log_user 0
log_file -noappend -a ${logfile}_cluster.conf
send "cphaprob -a if\n"
expect {
"*]#" {}
}
log_file
send_user "\n${hostname} cluster configuration saved\n"
send "exit\r"
exit 0