NAME
POE::Component::OpenSSH - Nonblocking SSH Component for POE using Net::OpenSSH
VERSION
Version 0.02
SYNOPSIS
Need nonblocking SSH? You like Net::OpenSSH? Try out this stuff right here.
use POE::Component::OpenSSH;
my $ssh = POE::Component::OpenSSH->new( args => [ $host, user => $user ] );
# perhaps using verbose, debug?
my $ssh = POE::Component::OpenSSH->new(
args => [ ''root@host', passwd => $pass ],
verbose => 1, # turns on POE::Component::Generic verbose
debug => 1, # turns on POE::Component::Generic debug
);
...
Here is an example using MooseX::POE. If you know POE::Session, you can use that too:
package Runner;
use MooseX::POE;
has 'host' => ( is => 'ro', isa => 'Str', default => 'localhost' );
has 'user' => ( is => 'ro', isa => 'Str', default => 'root' );
has 'pass' => ( is => 'ro', isa => 'Str', default => 'psss' );
has 'cmd' => ( is => 'ro', isa => 'Str', default => 'w' );
sub START {
my $self = $_[OBJECT];
my $ssh = POE::Component::OpenSSH->new(
args => [
$self->host,
user => $self->user,
passwd => $self->passwd,
],
);
# remember, $ssh is just POE::Component::OpenSSH
# you want the Net::OpenSSH object (or psuedo-object)
$ssh->obj->capture( { event => 'parse_cmd' }, $cmd );
}
event 'parse_cmd' => sub {
my ( $self, $output ) @_[ OBJECT, ARG1 ];
my $host = $self->host;
print "[$host]: $output";
};
package main;
my @machines = ( qw( server1 server2 server3 ) );
foreach my $machine (@machines) {
Runner->new(
host => $machine,
pass => 'my_super_pass',
cmd => 'uname -a',
);
}
DESCRIPTION
This module allows you to use SSH (via Net::OpenSSH) in a nonblocking manner.
I kept having to write this small thing each time I needed nonblocking SSH in a project. I got tired of it so I wrote this instead.
You might ask 'why put the args in an "args" attribute instead of straight away attributes?' Because Net::OpenSSH has a lot of options and they may collide with POE::Component::Generic's options and I don't feel like maintaining the mess.
It's on Github so you can patch it up if you want (I accept patches... and foodstamps).
AUTHOR
Sawyer X, <xsawyerx at cpan.org>
BUGS
Please report any bugs or feature requests to bug-poe-component-openssh at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=POE-Component-OpenSSH. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
Also available is the Github's issue tracker at http://github.com/xsawyerx/poe-component-openssh/issues.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc POE::Component::OpenSSH
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=POE-Component-OpenSSH
Github issue tracker
Github page
http://github.com/xsawyerx/poe-component-openssh/tree/master
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
SEE ALSO
If you have no idea what I'm doing (but you generally know what POE is), check these stuff:
If you don't know POE at all, check POE.
DEPENDENCIES
These are the actual dependencies, though I don't use Moose or POE directly but rather MooseX::POE.
ACKNOWLEDGEMENTS
All the people involved in the aforementioned projects and the Perl community.
COPYRIGHT & LICENSE
Copyright 2009 Sawyer X, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.