Documentation ¶
Overview ¶
Package vty provides the ability to execute remote commands (e.g. CLI) on an existing remote connection (any transport that implements the Connector interface). To execute remote commands, a new configuration session needs to be opened:
sess, err := NewSession(conn) // handle error! defer sess.Close()
Then remote commands can be executed using the ExecCMD method of the session:
output, err := sess.ExecCMD("show ver") // handle error!
Each command is a string that will be sent as the input via the open connection on a separate line. After sending the command (or multiple commands in one ExecCMD call), all the output will be read and returned, until the shell prompt is read from the connection or until the timeout expires.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connector ¶
type Connector interface { // GetVTY returns the interface to VTY for reading and writing. GetVTY() (io.Reader, io.Writer, error) // Close closes the VTY connection. Close() }
Connector provides the connection to VTY via various transports.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a VTY session handle.
func NewSession ¶
NewSession returns a new VTY session opened on provided connector. The session is supposed to be closed via Close().