EasyManua.ls Logo

Newport XPS-Q8 - 5 Example of a Tcl Script Redirection to a Telnet Session

Newport XPS-Q8
66 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...
XPS-Q8 Tcl Manual
5.0 Example of a Tcl Script Redirection to a telnet Session
The following example shows the redirection of a Tcl script to a telnet session the telnet
window displays the results of the Tcl execution (gets the library and the firmware
version).
# Set channel’s name to be used for telnet.
# In this example we assume it is passed to the script as the
# first argument, if not specified output to stdio.
# Open the channel for read mode and get its id,
# this is the id that will be passed to puts function.
if {$tcl_argv(0) != 0} {
set telnetOut [ open "/dev/$tcl_argv(0)" r+]
} else {
set telnetOut stdout
}
# Get library version
set code [catch "GetLibraryVersion strVersion"]
if {$code != 0} {
ErrorStringGet $socketID $code strError
puts $telnetOut "GetLibraryVersion Not OK => error = $code : $strError"
# Force transfer to channel’s output buffer
flush $telnetOut
} else {
puts $telnetOut "Library Version = $strVersion"
# Force transfer to channel’s output buffer
flush $telnetOut
}
# Open socket
set TimeOut 60
set code [catch "OpenConnection $TimeOut socketID"]
if {$code != 0} {
puts $telnetOut "OpenConnection failed => $code"
# Force transfer to channel’s output buffer
flush $telnetOut
} else {
# Get firmware version
set code [catch "FirmwareVersionGet $socketID strVersion"]
if {$code != 0} {
ErrorStringGet $socketID $code strError
puts $telnetOut "FirmwareVersionGet Not OK => error = $code :
$strError"
# Force transfer to channel’s output buffer
flush $telnetOut
} else {
puts $telnetOut "Firmware Version = $strVersion"
# Force transfer to channel’s output buffer
flush $telnetOut
}
# Close TCP socket
set code [catch "TCP_CloseSocket $socketID"]
}
EDH0307En1041 — 10/17
19

Table of Contents

Other manuals for Newport XPS-Q8

Related product manuals