EasyManua.ls Logo

Lantronix EMG Series

Lantronix EMG Series
482 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
12: Scripts
EMG™ Edge Management Gateway User Guide 278
Tcl Custom Script - EMG CLI Session
An example of a Tcl Custom Script that interacts with a CLI session:
#! tcl
# Script to get the current internal temperature of the EMG
# Accepts one optional command line parameter for location
set emgTemp "unknown"
set location ""
# 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} {
puts "Internal temperature of the $location EMG at $date"
} else {
puts "Internal temperature of the EMG at $date"
}
set io [open "| clisession -U sysadmin" r+]
set loggedIn false
while {! $loggedIn} {
set len [gets $io line]
if {[string first "Invalid local user" $line] != -1} {
puts "Invalid local user passed to clisession"
break
}
if {[string first "For a list of commands" $line] != -1} {
puts $io "\n"
flush $io
}
if {[string first ">" $line] != -1} {
set loggedIn true
}
}
if {! $loggedIn} {
exit 1
}
puts $io "show temp"
flush $io
set gotTemp false
while {! $gotTemp} {
set len [gets $io line]
if {[string first "Current Internal Temperature" $line] != -1} {
set emgTemp [string range $line [expr {[string first ":" $line] +
1}] end]

Table of Contents

Other manuals for Lantronix EMG Series

Related product manuals