1Net::CLI::Interact::TraUnsseprorCto:n:tBraisbeu(t3e)d PeNrelt:D:oCcLuIm:e:nItnatteiroanct::Transport::Base(3)
2
3
4

NAME

6       Net::CLI::Interact::Transport::Base - Spawns an Interactive CLI Session
7

DESCRIPTION

9       This module provides a generic cross-platform API with the purpose of
10       interacting with a command line interface.
11
12       On Windows the IPC::Run module is used and on Unix when IO::Pty is
13       available (it requires a compiler) Net::Telnet, else "IPC::Run". In all
14       cases, a program such as openssh is started and methods provided to
15       send and receive data from the interactive session.
16
17       You should not use this class directly, but instead inherit from it in
18       specific Transport that will set the application command line name, and
19       marshall any runtime options. The OS platform is detected
20       automatically.
21

INTERFACE

23   init
24       This method must be called before any other, to bootstrap the
25       application wrapper module (IPC::Run or Net::Telnet). However, via
26       Net::CLI::Interact's "cmd", "match" or "find_prompt" it will be called
27       for you automatically.
28
29       Two attributes of the specific loaded Transport are used. First the
30       Application set in "app" is of course required, plus the options in the
31       Transport's "runtime_options" are retrieved, if set, and passed as
32       command line arguments to the Application.
33
34   connect_ready
35       Returns True if "connect" has been called successfully, otherwise
36       returns False.
37
38   disconnect
39       Undefines the application wrapper flushes any output data buffer such
40       that the next call to "cmd" or "macro" will cause a new connection to
41       be made.  Useful if you intentionally timeout a command and end up with
42       junk in the output buffer.
43
44   do_action
45       When passed a Net::CLI::Interact::Action instance, will execute the
46       contained instruction on the connected CLI. This might be a command to
47       "send", or a regular expression to "match" in the output.
48
49       Features of the commands and prompts are supported, such as
50       Continuation matching (and slurping), and sending without an output
51       record separator.
52
53       On failing to succeed with a Match, the module will time-out (see
54       "timeout", below) and raise an exception.
55
56       Output returned after issuing a command is stored within the Match
57       Action's "response" and "response_stash" slots by this method, with the
58       latter then marshalled into the correct "send" Action by the ActionSet.
59
60   put( @data )
61       Items in @data are joined together by an empty string and sent as input
62       to the connected program's interactive session.
63
64   pump
65       Attempts to retrieve pending output from the connected program's
66       interactive session. Returns true if there is new data available in the
67       buffer, else will time-out and raise a Perl exception. See "buffer" and
68       "timeout".
69
70   flush
71       Empties the buffer used for response data returned from the connected
72       CLI, and returns that data as a single text string (possibly with
73       embedded newlines).
74
75   timeout( $seconds? )
76       When "do_action" is polling for response data matching a regular
77       expression Action, it will eventually time-out and throw an exception
78       if nothing matches and no more data arrives.
79
80       The number of seconds to wait is set via this method, which will also
81       return the current value of "timeout". The default value is 10 seconds.
82
83   irs_re
84       Returns the Regular Expression reference used to split lines of
85       response from the connected device. In the end, you will only receive
86       data from this module separated by the "ors" value (by default a
87       newline character). The "irs_re" is used internally by the module and
88       is:
89
90        qr/(?:\015\012|\015|\012)/  # i.e. CRLF or CR or LF
91
92   ors
93       Line separator character(s) appended to a command sent to the connected
94       CLI.  This defaults to a newline on the application's platform.
95
96   logger
97       Slot for storing a reference to the application's Logger object.
98
99   is_win32
100       Returns true if the current platform is Windows. Can be called as
101       either a class or instance method.
102
103   app
104       Location and name of the program used to establish an interactive CLI
105       session.  On Unix platforms this will be "ssh" (openssh), "telnet", or
106       "cu" (serial line). On Windows this must be the "plink.exe" program.
107
108   connect_options
109       Slot for storing a set of options for the specific loaded Transport,
110       passed by the user of Net::CLI::Interact as a hash ref. Do not access
111       this directly, but instead use "runtime_options" from the specific
112       Transport class.
113
114   wrapper
115       Slot for storing the application wrapper instance (IPC::Run or
116       Net::Telnet).  Do not mess with this unless you know what you are
117       doing.
118
119   buffer
120       After "pump" returns successfully, the output most recently received is
121       stored in this slot. Do not access this directly, but instead use the
122       "flush" method.
123
124   stash
125       During long sections of output, this slot allows more efficient
126       detection of matches. Older data is placed here, and only the most
127       recent line of data is stored in the "buffer". That's why "flush" is
128       the only way to ensure you get all the output data in one go.
129

NOTES

131       FIXME: On Unix, when the Telnet transport is selected but "IP::Pty" is
132       unavailable, "Net::Telnet" can still be used, but currently "IPC::Run"
133       is used instead.
134
135
136
137perl v5.32.0                      2020-07N-e2t8::CLI::Interact::Transport::Base(3)
Impressum