NAME
Mnet::Expect - Create Expect objects with Mnet::Log support
SYNOPSIS
use Mnet::Expect;
my $expect = Mnet::Expect->new({ spawn => [qw(
ssh
-o StrictHostKeyChecking=no
-o UserKnownHostsFile=/dev/null
1.2.3.4
)]});
$expect->send("ls\r");
$expect->close;
DESCRIPTION
This module can be used to create new Mnet::Expect objects, log spawned process expect activity, and close Mnet::Expect sessions.
This module requires that the perl Expect module is installed.
The methods in this object are used by other Mnet::Expect modules.
new
$expect = Mnet::Expect->new(\%opts)
This method can be used to create new Mnet::Expect objects.
The following input opts may be specified:
log_id refer to perldoc Mnet::Log new method
raw_pty can be set 0 or 1, refer to perldoc Expect
spawn command and args array ref, or space separated string
winsize specify session rows and columns, default 99999x999
An error is issued if there are spawn problems.
For example, the following will spawn an ssh expect session to a device:
my $expect = Mnet::Expect->new({ spawn => [qw/
ssh
-o StrictHostKeyChecking=no
-o UserKnownHostsFile=/dev/null
1.2.3.4
/]});
Note that all Mnet::Expect session activity is logged for debugging, refer to the Mnet::Log module for more information.
close
$expect->close
Attempt to call hard_close for the current Expect session, and send a kill signal if the process still exists. The Expect sesssion is set to udnefined.
expect
$expect->expect
Returns the underlying expect object used by this module, for access to fetures that may not be supported directly by Mnet::Expect modules. Refer to perldoc Expect for more information.
TESTING
This module supports Mnet::Test --replay functionality for other Mnet::Expect submodules. Refer to those other Mnet::Expect submodules for more information.