Mnet::Expect::Cli::Ios - Expect sessions to cisco ios devices
my $opts = { spawn => "ssh 1.2.3.4", prompt => 1 }; my $expect = Mnet::Expect::Cli->new($opts); $expect->enable($password) or die "enable failed"; my $output = $expect->command("show version"); $expect->close;
This module can be used to create new Mnet::Expect::Cli::Ios objects, which inherit Mnet::Expect::Cli methods.
$expect = Mnet::Expect::Cli::Ios->new(\%opts)
This method can be used to create new Mnet::Expect::Cli::Ios objects.
The following input opts may be specified, in addition to options from the Mnet::Expect::Cli and Mnet::Expect modules:
enable set to password for enable mode during login enable_in stderr prompt for stdin entry of enable if not set enable_user default enable username set from username option failed_re default recognizes lines starting w/ios % error char paging_key default space key to send for ios pagination prompts paging_re default recognizes ios pagination prompt --more-- prompt_re defaults to ios user or enable mode prompt
An error is issued if there are login problems.
For example, the following call will start an ssh expect session to a device:
my $opts = { spawn => "ssh 1.2.3.4" }; my $expect = Mnet::Expect::Cli->new($opts);
Set failed_re to detect failed logins faster, as long as there's no conflict with text that appears in login banners. For example:
(?i)(^\s*%|closed|error|denied|fail|incorrect|invalid|refused|sorry)
Refer to the Mnet::Expect::Cli and Mnet::Expect modules for more information.
$boolean = $expect->enable($password)
Use this method to check if an ios device session is currently in enable mode, and/or to enter enable mode on the device.
The input password will be used, or the enable and enable_in options for the current object. An error results if a password is needed and none was set.
A fatal error is issued if an enable password is required and none is set.
A value of true is returned if the ios device is at an enable mode command prompt, otherwise a value of false is returned.
$expect->close
This method sends the end and exit ios commands before closing the current expect session. Timeouts are gracefully handled. Refer to the close method in the Mnet::Expect module for more information.
Mnet::Test --record and --replay functionality are supported. Refer to the Mnet::Expect::Cli module for more information.
Expect
Mnet
Mnet::Expect
Mnet::Expect::Cli
Mnet::Test
To install Mnet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mnet
CPAN shell
perl -MCPAN -e shell install Mnet
For more information on module installation, please visit the detailed CPAN module installation guide.