in reply to Re^2: ssh not working
in thread ssh not working

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}

Replies are listed 'Best First'.
Re^4: ssh not working
by veeruch (Sexton) on Jul 05, 2006 at 14:31 UTC
    i have given what u suggested .but still same problem
    i can connect AIX server through putty and Winscp also
    i have doubt... can we use NET::SSH::Perl in Windows
    environment(my problem is i have to run .pl in windows and connected to AIX ,Sunsolaris for that can use
    Net::SSH::Perl in windows environment(Active State Perl)
      I have the same problem as described above - just curious if anyone managed to solve it? I can provide much more detail if required, but basically it seems it's not possible to grab STDOUT.