I have two suggestions:

1. This will work for SSH2, but if you are going to wind up supporting a mixture of Telnet, SSH1, and SSH2 clients, you will have a lot fewer headaches using Expect.pm from CPAN.

2. I'm not on a Windows box, so I can't check this, but... in the command $ssh->cmd('ls',"\n"); the "\n" is an optional stdin parameter. In this case, it is fed into ls, which doesn't read its standard input.

It may be that the Net::SSH::W32Perl problem described in its CPAN page "the shell() interface is not supported due to MSWin32's lack of support for select() on non-socket filehandles" also applies to the case where stdin and stdout are active at the same time.

I would try removing the "\n" parameter and see if that helps. If you need to pass some input to other commands, you could use echo commands to create a file and then redirect stdin to the file.


In reply to Re: SSH::W32Perl and STDOUT by quester
in thread SSH::W32Perl and STDOUT by spanko

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.