Dear PerlMonks,
I've been loving Net::SSH2 and have been using it for a few months. It's much easier to install (less dependancies than Net::SSH::Perl) and overall it's faster when hitting our remote servers. I've been working with the Net::SSH2 forum however they seem to have problems with their server lately. I'm hoping someone here might have some insights to help me along my way.
The Question/Problem
I'm trying to pull STDERR from my remote server. The idea is we want to trigger a subroutine to execute when STDERR traffic is detected. In the past I simply called the NET::SSH::Perl method register_handler. Here is how I used to do it
®ister_handler("STDERR", sub {
my($channel, $buffer) = @_;
print "** STDERR -- I received this: ", $buffer->byt
+es;
});
Dave Robins (the developer) mentioned I check out the POLL method to do something similar to this however I must be missing something. I've read perldoc however I'm not seeing where to call the subroutine from POLL. Here is the module I'm using
Net-SSH2-0.09
Here is how I'm trying to call it:
# Create the ssh2 object
my $ssh2 = Net::SSH2->new();
# Create my STDERR trigger
my $poll=Net::SSH2->poll( 1, 'pollerr');
# connect to remote server
$ssh2->connect($server) or die "** Failed to connect via Net::SSH2:
+ $!\n";
print "** Connect to server $server successful\n\n";
I've tried replacing 'pollerr' with STDERR and stderr. In both cases I get a message stating I can't use symbolic references. Only hard references are allowed.
Has anyone been successful in doing this? I'm also curious how I could use POLL to execute a subroutine when STDERR traffic is detected.
I've also tried using Net::SSH::Channel and calling the read method to read STDERR. It runs fine however nothing is captured when I run my sudo command. I've even tried the above against STDOUT just to see if I'm getting anything. No dice.
What else can I tell you about my situation?
Thanks a bunch!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.