OK, this will not work for Net::SSH::Perl -- I don't have that module installed, and I hear it is nontrivial on a Solaris platform. Besides, at some point I need to go home. But your problem intrigued me because I currently had no way to handle problems with my existing Net::SSH use. I played for quite a while with IO::Capture before I realized that the output from the Net::SSH->ssh() method was neither STDERR nor STDOUT for my script.

So I wrote a little program using Net::SSH->sshopen3() which seems to work pretty well in both the happy and unhappy cases:
#!/usr/local/bin/perl -w use Net::SSH qw(sshopen3); use strict; Main: { my $host = 'nobody@nowhere.com'; my @command = ('ls -al;', 'echo Howdy!'); my $reader = IO::File->new(); my $writer = IO::File->new(); my $error = IO::File->new(); sshopen3( $host, $writer, $reader, $error, @command ) or die $!; local $/ = undef; my $output_stream = <$reader>; my $error_stream = <$error>; if ( length $error_stream ) { print "SSH error: $error_stream"; } if ( length $output_stream ) { print "SSH output: $output_stream"; } }
If you use the $host string I have provided, you should see a message to that effect in $error_stream, which you could capture and reformat for display in your CGI script. I hope that helps you at least a little.

No good deed goes unpunished. -- (attributed to) Oscar Wilde

In reply to Re^4: Net::SSH question by ptum
in thread Net::SSH question by GaijinPunch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.