The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mnet::Expect::Cli::Ios - Expect sessions to cisco ios devices

SYNOPSIS

    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;

DESCRIPTION

Mnet::Expect::Cli::Ios can be used to spawn Expect processes which can be used to programmatically control command line sessions to cisco ios devices, with support for Mnet options, logging, caching, and testing.

Refer to the perl Expect module for more information. Also refer to the Mnet::Expct and Mnet::Expct::Cli modules.

METHODS

Mnet::Expect::Cli::Ios implements the methods listed below.

new

    $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 prompts

An error is issued if there are login problems.

For example, the following call will start an ssh expect session to a device with host key checking disabled:

    my @spawn = qw(ssh);
    push @spawn, qw(-o StrictHostKeyChecking=no);
    push @spawn, qw(-o UserKnownHostsFile=/dev/null);
    push @spawn, qw(1.2.3.4);
    my $opts = { spawn => \@spawn };
    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.

enable

    $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.

close

    $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.

TESTING

Mnet::Test --record and --replay functionality are supported. Refer to the TESTING perldoc section of Mnet::Expect::Cli module for more information.

SEE ALSO

Expect

Mnet

Mnet::Expect

Mnet::Expect::Cli

Mnet::Log

Mnet::Opts::Cli

Mnet::Test