-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcontrol-switched-rack-pdu.exp
More file actions
executable file
·55 lines (51 loc) · 1.12 KB
/
control-switched-rack-pdu.exp
File metadata and controls
executable file
·55 lines (51 loc) · 1.12 KB
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
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/expect -f
set username [lindex $argv 0]
set password [lindex $argv 1]
set hostname [lindex $argv 2]
set outlet [lindex $argv 3]
if {[llength $argv] == 0} {
send_user "Usage: scriptname username \'password\' hostname outlet\n"
exit 1
}
spawn telnet $hostname
expect "User Name :"
send "$username\r"
expect "*?assword*"
send "$password\r"
expect "\n> "
send "1\r"
expect " Device Manager *\n> "
send "2\r"
expect " Outlet Management *\n> "
send "1\r"
expect " Outlet Control*\n> "
send "$outlet\r"
expect " Control Outlet*\n> "
send "1\r"
expect " Immediate Reboot*\n> "
send "3\r"
expect -re "Enter 'YES' to continue.*: "
send "YES\r"
expect "Press <ENTER> to continue..."
send "\r"
expect " Immediate On*\n> "
sleep 5
send "1\r"
expect -re "Enter 'YES' to continue.*: "
send "YES\r"
expect "Press <ENTER> to continue..."
send "\r"
expect " Control Outlet*\n> "
send "\033"
expect " Control Outlet*\n> "
send "\033"
expect " Outlet Control*\n> "
send "\033"
expect " Outlet Management *\n> "
send "\033"
expect " Device Manager *\n> "
send "\033"
expect " Control Console * Logout*\n> "
send "4\r"
expect eof
close $spawn_id