Net::CLI::Interact::Role::Engine - Statement execution engine
version 2.131260
This module is the core of Net::CLI::Interact, and serves to take entries from your loaded Phrasebooks, issue them to connected devices, and gather the returned output.
Execute a single command statement on the connected device, and consume output until there is a match with the current prompt. The statement is executed verbatim on the device, with a newline appended.
The following options are supported:
timeout => $seconds
Sets a value of timeout for the Transport local to this call of cmd, that overrides whatever is set in the Transport, or the default of 10 seconds.
timeout
cmd
no_ors => 1
When passed a true value, a newline character (in fact the value of ors) will not be appended to the statement sent to the device.
ors
match => $name | $regexpref | \@names_and_regexprefs
Allows this command (only) to complete with a custom match, which must be one or more of either the name of a loaded phrasebook Prompt or your own regular expression reference (qr//). The module updates the current prompt to be the same value on a successful match.
qr//
In scalar context the last_response is returned (see below). In list context the gathered response is returned as a list of lines. In both cases your local platform's newline character will end all lines.
last_response
Execute the commands contained within the named Macro, which must be loaded from a Phrasebook. Options to control the output, including variables for substitution into the Macro, are passed in the %options hash reference.
%options
params => \@values
If the Macro contains commands using sprintf Format variables then the corresponding parameters must be passed in this value as an array reference.
sprintf
Values are consumed from the provided array reference and passed to the send commands in the Macro in order, as needed. An exception will be thrown if there are insufficient parameters.
send
Sets a value of timeout for the Transport local to this call of macro, that overrides whatever is set in the Transport, or the default of 10 seconds.
macro
An exception will be thrown if the Match statements in the Macro are not successful against the output returned from the device. This is based on the value of timeout, which controls how long the module waits for matching output.
Returns the gathered output after issuing the last recent send command within the most recent cmd or prompt. That is, you get the output from the last command sent to the connected device.
prompt
In scalar context all data is returned. In list context the gathered response is returned as a list of lines. In both cases your local platform's newline character will end all lines.
Returns the complete ActionSet that was constructed from the most recent macro or cmd execution. This will be a sequence of Actions that correspond to send and match statements.
match
In the case of a Macro these directly relate to the contents of your Phrasebook, with the possible addition of match statements added automatically. In the case of a cmd execution, an "anonymous" Macro is constructed which consists of a single send and a single match.
See the following for further interface details:
Net::CLI::Interact::Role::Prompt
Oliver Gorwits <oliver@cpan.org>
This software is copyright (c) 2013 by Oliver Gorwits.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Net::CLI::Interact, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::CLI::Interact
CPAN shell
perl -MCPAN -e shell install Net::CLI::Interact
For more information on module installation, please visit the detailed CPAN module installation guide.