session - open/close/control sessions
SYNOPSIS
package require libcisco
|
The session command performs one of several session operations.
COMMANDS
Host is the IP address or hostname of the target device.
LinePw is the expected line password.
TacUsername is optional. It is the TACACS+/RADIUS username.
TacUserPw is optional. It is the TACACS/RADIUS login password.
Supported options are as follows:
On success, session open returns an Expect spawn ID. More than
likely, you will not need to use this ID unless you are very familiar with
Expect. Even so, it is best to use the libcisco routines like
sendCmd to interact with the session. Failure to do so will result
in unpredictable results. On error a short text string is returned
beginning with the string "err".
EnablePw is the enable password.
TacUsername is optional. It is the TACACS+/RADIUS username.
TacEnablePw is optional. It is the TACACS+/RADIUS enable password.
The following options are supported:
On success session enable returns 0. On error, a short text
message is returned beginning with the string "err".
InfoElement is the information element to be returned. Valid options
for InfoElement are as follows:
On success session info returns the requested information element.
On error, a short text message is returned beginning with the string "err".
Module identifies the module number to be session'd to.
LinePw is optional. It is the line password on the target module.
TacUsername is optional. It is the TACACS+/RADIUS username to be
used during login.
TacUserPw is optional. It is the TACACS+/RADIUS password to be
used during login.
Supported options are as follows:
On success session module returns 0. On error, a short text
message is returned beginning with the string "err".
LogText is the string of text to be added to the logfile.
On success, session logger returns 0. On error, a short text
message is returned beginning with the string "err".
Supported options are as follows:
On success, session close returns 0. On error, a short text
message is returned beginning with the string "err".
EXAMPLE
The following code will open a telnet session to 192.168.1.1 logging in with
a password of "cisco". It will then put the device in "enable" mode
using a password of "san-fran". After issuing any number of commands
on the device (...), the session is closed. For the sake of brevity and
simplicity, no error checking is performed.
#!/bin/sh # the next line restarts using the tclsh interpreter \ exec tclsh "$0" "$@" package require libcisco namespace import libcisco::* session open 192.168.1.1 cisco session enable san-fran (...) session close |