9: Device Ports
SLC™ 8000 Advanced Console Manager User Guide 206
Note:
For CLI sessions, a local user name should be given
For Device Port sessions, the $devicePort variable will be used by the SLC to connect
the script to the appropriate Device Port. The -noecho flag may be passed to spawn
command.
Expect script - CLI session
spawn clisession -U <username>
Expect script - Device Port session
spawn portsession -p $devicePort
Tcl script - CLI session
set io [open "| clisession -U <username>" r+]
Tcl script - Device Port session
set io [open "| portsession -p $devicePort" r+]
Python script - CLI session
subprocess.Popen(['clisession', '-U', '<username>'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
Python script - Device Port session
subprocess.Popen(['portsession', '-p', devicePort],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
5. It is recommended that scripts that spawn clisession only be used with the set script
runcli command (and not the connect script command), and that scripts that spawn
portsession only be used with the connect script command (and not the set script
runcli command).
6. The script cannot contain commands which spawn or fork other commands, read or write files
on the SLC filesystem, or interrogate the SLC filesystem. The list of commands that are not
allowed for Expect scripts includes "fork", "open", "exp_open", "exec",
"system", "log_file", "pwd".
7. For scripts that return an exit code, the SLC will interpret an exit code of zero as a successful
exit code, and any non-zero exit code as an error. Non-zero exit codes are displayed (at the
CLI) or logged (for scripts that are run by the script scheduler).
Example Scripts
Interface Script—Monitor Port
The Monitor Port (Monport) script connects directly to a device port by logging into the SLC
port,
gets the device hostname, loops a couple of times to get port interface statistics, and logs out. The
following is the script:
set monPort 7
set monTime 5