No pty allocated, pty required..
Use use_pty => 1 in the constructor; also, the customer server expects SSH2, so use protocol => 2 in the constructor also. Here's the way that I would do it:
#!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; my $user = 'user'; my $pass = 'password'; my $cmd = "ls /root"; my $ssh = Net::SSH::Perl->new('localhost', debug => 1, protocol => 2, use_pty => 1, ); $ssh->login($user, $pass) ; if ($cmd) { my($stdout, $stderr, $exit) = $ssh->cmd($cmd); print $stdout if $stdout; print $stderr if $stderr; } else { eval "use Term::ReadKey;"; ReadMode('raw'); eval "END { ReadMode('restore') };"; $ssh->shell; print "Connection to host closed.\n"; } __END__
In reply to Re: Net::SSH::Perl returns error on pty allocation
by Khen1950fx
in thread Net::SSH::Perl returns error on pty allocation
by gdanenb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |