
9: Device Ports
SLC™ 8000 Advanced Console Manager User Guide
221
time.sleep(.500)
p.wait()
print("Script completed.")
sys.exit(0)
Tcl Custom Script - SLC 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 SLC
# Accepts one optional command line parameter for location
set slcTemp "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 SLC at $date"
} else {
puts "Internal temperature of the SLC 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