First, can you login into the remote machine using an ssh command line client, such as http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html ?

If you login to a remote machine, your login shell is spawned - one of sh, ksh, bash, csh, tcsh. You can lookup ypur shell in the file /etc/passwd on the remote machine. Please consult the login manual page of the remote system for details on the login process, and the manual page for your login shell for it's startup sequence.

On startup, the login shell processes various rc files to set $PATH, the value of $TERM, the height and width of the terminal, system wide aliases for commands and so on.

If such code as setting up the terminal is carried out regardless whether there was a controlling terminal (pty) set up for this session, various commands to set up the environment could hang. E.g. a shell could ask for your terminal type at the command prompt, if it is unable to determine it from the environment.

Depending on the shell and remote system, the shell startup files are one ore more of /etc/profile, /etc/bashrc, /etc/csh.csh, $HOME/.profile, $HOME/.bashrc, $HOME/.cshrc etc. Check if those files contain terminal initialization code, and if possible, disable it.

Since Net::SSH::W32Perl doesn't support the shell method, there should be no pty allocated, but you can explicitly disable it.

Try the following:

use Net::SSH::W32Perl; my $ssh = Net::SSH::W32Perl->new($host, debug => 1, use_pty => 0, ); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd("ls");

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

In reply to Re^3: ssh not working by shmem
in thread ssh not working by veeruch

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.