Please show some effort on your part by reducing the problems to the absolute minimum of code. In your case, the problem is that your child process running the ssh command does not produce output. This is because you wrongly transcribed merlyn's code:

# Original code: =42= my $buf = ""; =43= while (<F>) { =44= $buf .= $_; =45= $cache->set($session, [0, $buf]); =46= } =47= $cache->set($session, [1, $buf]); =48= exit 0;

Your code does not read from the STDOUT of the SSH process. In fact, I don't think you understood how Net::SSH works at all. I think it directly returns the output of the command after the command has run, so using Net::SSH won't help you, at least in the way you've used it here:

$cmd="ls -l"; my($stdout, $stderr, $exit) = $ssh->cmd($cmd); my $buf = ""; while ($stdout) { $buf .= $_; $cache->set($session, [0, $buf +]); } $cache->set($session, [1, $buf]);

Please review your code and the documentation for Net::SSH and consider how they can be used for your program.


In reply to Re^3: Asynchronous Processing a command execution by Corion
in thread Asynchronous Processing a command execution by Alfaromeo

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.