12: Scripts
EMG™ Edge Management Gateway User Guide
266
Expect Custom Script - EMG CLI Session
An example of an Expect Custom Script that interacts with an EMG CLI session:
#! expect
# script to get the current internal temperature of the EMG
# accepts one optional command line parameter for location
set emgPrompt ">"
set emgTemp "unknown"
set location ""
proc myprint {str} {
send_user -- "$str\n"
}
proc abortSession {err} {
send_user "Error $err. Terminating session.\n"
exit $err
}
# Are there any command line parameters?
if {$argc > 0} {
set location [lindex $argv 0]
}
set now [clock seconds]
set date [clock format $now -format {%D %R}]
if {$argc > 0} {
myprint "Internal temperature of the $location EMG at $date"
} else {
myprint "Internal temperature of the EMG at $date"
}
# spawn the CLI session
if {[catch {spawn -noecho clisession -U sysadmin} 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
# Wait for the first prompt
set loggedIn false
while {! $loggedIn} {
Summary of Contents for EMG Series
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...