12: Scripts
EMG™ Edge Management Gateway User Guide
268
Expect Custom Script - EMG Device Port Session
An example of an Expect Custom Script that interacts with a EMG Device Port (in this example a
ServerTech PDU is connected to a Device Port):
#! expect
#
# Script to get the load of a ServerTech PDU outlet
#
set pduPrompt ">"
set pduLoad "unknown"
proc myprint {str} {
send_user -- "$str\n"
}
proc abortSession {err} {
send_user "Error $err. Terminating session.\n"
exit $err
}
set now [clock seconds]
set date [clock format $now -format {%D %R}]
myprint "Load of ServerTech PDU outlet B1 at $date"
# spawn the port session on a device port
if {[catch {spawn -noecho portsession -p $devicePort} result]} {
abortSession 1
}
set sessionId $spawn_id
# Handle eof
expect_after {
-i $sessionId eof {
myprint "Session unexpectedly terminated."
abortSession 2
}
}
set timeout 10
log_user 0
#
# Login to the PDU
# The "Error:*" pattern matches all error messages output by portsession
#
send "\n"
expect {
"Username:" { send "admn\n" }
"Error:*\r\n" { send_user $expect_out(0,string); abortSession 2 }
}
expect "Password:"
send "admn\n"
Summary of Contents for EMG 7500
Page 100: ...7 Networking EMG Edge Management Gateway User Guide 100 Figure 7 5 Network Wireless Settings ...
Page 353: ...15 Maintenance EMG Edge Management Gateway User Guide 353 Figure 15 12 About EMG ...
Page 474: ...EMG Edge Management Gateway User Guide 474 Figure E 3 EU Declaration of Conformity ...
Page 475: ...EMG Edge Management Gateway User Guide 475 Figure E 4 EU Declaration of Conformity continued ...