POE::Component::Client::Telnet - A POE component that provides non-blocking access to Net::Telnet and other subclasses of Net::Telnet.
use POE::Component::Client::Telnet; my $poco = POE::Component::Client::Telnet->new( alias => 'telnet', # optional; You can use $poco->session_id() instead debug => 1, # optional; 1 to turn on debugging options => { trace => 1 }, # optional; Options passed to the internal session package => 'Net::Telnet::Cisco', # optional; Allows use of other Net::Telnet telnet_options => [ ], # optional; Options passed to Net::Telnet->new() ); # Start your POE session, then... $kernel->post('telnet' => open => { event => 'result' },"rainmaker.wunderground.com"); sub result { my ($kernel,$ref) = @_[KERNEL,ARG0]; if ( $ref->{result} ) { print "connected: $ref->{result}\n"; } else { print STDERR join(' ', @{ $ref->{error} ) . "\n"; } }
POE::Component::Client::Telnet is a POE component that provides a non-blocking wrapper around Net::Telnet, or any other module based on Net::Telnet.
Consult the Net::Telnet documentation for more details.
Takes a number of arguments, all of which are optional. 'alias', the kernel alias to bless the component with; 'debug', set this to 1 to see component debug information; 'options', a hashref of POE::Session options that are passed to the component's session creator; 'telnet_options', an optional array ref of options that will be passed to Net::Telnet->new(); 'package', an optional package name that is a base of Net::Telnet, like Net::Telnet::Cisco.
Takes no arguments, returns the POE::Session ID of the component. Useful if you don't want to use aliases.
This method provides an alternative object based means of posting events to the component. First argument is the event to post, following arguments are sent as arguments to the resultant post.
$poco->yield( open => { event => 'result' }, "localhost" );
This method provides an alternative object based means of calling events to the component. First argument is the event to call, following arguments are sent as arguments to the resultant call.
$poco->call( open => { event => 'result' }, "localhost" );
All Net::Telnet methods can be called, but the first param must be the options hash as noted below in the INPUT section below.
For example:
$poco->open( { event => 'opened' },"localhost" );
One exception, the 'option_callback' method accepts an event name instead of a code ref. If called with no params, 'result' will be the event currently set. Also, when the callback is fired, 'result' will be an array ref of $option, $is_remote, $is_enabled, $was_enabled, $buf_position. See the 'option_callback' method of Net::Telnet for details.
These are the events that the component will accept. Each event requires a hashref as an argument with the following keys: 'event', the name of the event handler in *your* session that you want the result of the requested operation to go to. 'event' is needed for all requests that you want a response to.
It is possible to pass arbitary data in the request hashref that could be used in the resultant event handler. Simply define additional key/value pairs of your own. It is recommended that one prefixes keys with '_' to avoid future clashes.
For each requested operation an event handler is required. ARG0 of this event handler contains a hashref.
The hashref will contain keys for 'state', and 'result'. 'state' is the operation that was requested, 'result' is what the function returned.
This is data returned from the function you called. Usually a scalar, but can be an array ref when using 'option_callback'.
In the event of an error occurring this will be defined. It is an scalar which contains the error.
David Davis <xantus@cpan.org>
POE, Net::Telnet, Net::Telnet::Cisco, Net::Telnet::Netscreen, Net::Telnet::Options
Please rate this module. http://cpanratings.perl.org/rate/?distribution=POE-Component-Client-Telnet
Probably. Report them here: http://rt.cpan.org/NoAuth/ReportBug.html?Queue=POE%3A%3AComponent%3A%3AClient%3A%3ATelnet
BinGOs for POE::Component::Win32::Service that helped me get started.
Copyright 2005 by David Davis and Teknikill Software
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install POE::Component::Client::Telnet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POE::Component::Client::Telnet
CPAN shell
perl -MCPAN -e shell install POE::Component::Client::Telnet
For more information on module installation, please visit the detailed CPAN module installation guide.