11: Scripts
EMG™ Edge Management Gateway User Guide
224
set emgTemp $expect_out(1,string)
myprint "Temperature: $emgTemp"
exp_send "logout\n"
sleep .5
close
exit 0
This script can be run manually at the CLI:
[emga508] set script runcli cliExample parameters "East Data Center"
Internal temperature of the East Data Center SLC at 01/27/2019 02:07
Temperature: 48C (118F)
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
}
}