POE::Component::Generic::Net::SSH2

POE::Component::Generic::Net::SSH2 is a POE component that provides non-blocking access to Net::SSH2.
Download

POE::Component::Generic::Net::SSH2 Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Philip Gwyn
  • Publisher web site:
  • http://search.cpan.org/~gwyn/

POE::Component::Generic::Net::SSH2 Tags


POE::Component::Generic::Net::SSH2 Description

POE::Component::Generic::Net::SSH2 is a POE component that provides non-blocking access to Net::SSH2. POE::Component::Generic::Net::SSH2 is a POE component that provides non-blocking access to Net::SSH2.SYNOPSIS use POE::Component::Generic::Net::SSH2; my $ssh = POE::Component::Generic::Net::SSH2->create( alias => 'my-ssh', verbose => 1, debug => 0 ); my $channel; POE::Session->create( inline_states => { _start => sub { $poe_kernel->delay( 'connect', $N ); }, connect => sub { $ssh->connect( {event=>'connected'}, $HOST, $PORT ); }, connected => sub { $ssh->auth_password( {event=>'login'}, $USER, $PASSWORD ); }, error => sub { my( $resp, $code, $name, $error ) = @_; die "Error $name ($code) $error"; }, login => sub { my( $resp, $OK ) = @_; unless( $OK ) { $ssh->error( {event=>'error', wantarray=>1} ); return; } $poe_kernel->yield( 'cmd_do' ); }, ################ cmd_do => sub { $ssh->cmd( { event=>'cmd_output', wantarray=>1 }, "ls -l" ); return; }, cmd_output => sub { my( $resp, $stdout, $stderr ) = @_; warn "Contents of home directory on $HOST:n$stdoutn"; $poe_kernel->yield( 'exec_do' ); }, exec_do => sub { $ssh->exec( { event=>'exec_running', wantarray=>0 }, "cat - >$FILE", StdoutEvent => 'exec_stdout', StderrEvent => 'exec_stderr', ClosedEvent => 'exec_closed', ErrorEvent => 'exec_error' ); }, exec_running => sub { my( $resp, $ch ) = @_; # keep channel alive $channel = $ch; $channel->write( {}, "CONTENTS OF THE FILE" ); $channel->send_eof( {} ); }, exec_error => sub { my( $code, $name, $string ) = @_; die "ERROR: $name $string"; }, exec_stderr => sub { my( $text, $bytes ) = @_; die "STDERR: $text"; return; }, exec_stdout => sub { my( $text, $bytes ) = @_; warn "STDOUT: $text"; return; }, exec_closed => sub { undef( $channel ); $ssh->shutdown; }, } ); Requirements: · Perl


POE::Component::Generic::Net::SSH2 Related Software