This code(given below) is working fine for all the command but for some
command it is not able to print the output.
I am getting the following output
==================
 w
52 column window is too narrow
==================
Similarly for top it is not printing all the field .
top -cd2
top - 20:36:28 up 21:30, 18 users,  load average: 1.
Tasks:  38 total,   1 running,  37 sleeping,   0 sto
Cpu(s):  8.4%us,  0.4%sy,  0.0%ni, 90.8%id,  0.3%wa,
Mem:   1025056k total,  1003548k used,    21508k fre
Swap:  2031608k total,   103608k used,  1928000k fre

Actual top output on the same system is as below

top -cd2

top - 20:37:05 up 21:30, 17 users,  load average: 1.10, 1.07, 1.00
Tasks:  34 total,   1 running,  33 sleeping,   0 stopped,   0 zombie
Cpu(s):  8.5%us,  0.4%sy,  0.0%ni, 90.8%id,  0.3%wa,  0.0%hi,  0.0%si,
0.0%st
Mem:   1025056k total,   994780k used,    30276k free,     2940k buffers
Swap:  2031608k total,   103600k used,  1928008k free,    86892k cached

============================

#!/usr/bin/perl -w
use strict;
use Net::SSH::Perl;
my $host = '192.168.0.114';
my $username = 'pratap';
my $login_passwd = 'pratap123';
my $ssh = Net::SSH::Perl->new($host, $username);
$ssh->config->set('interactive', 1)
    unless defined $ssh->config->get('interactive');

$ssh->login($username, $login_passwd);
my $cmd;
if ($cmd) {
    my($out, $err, $exit) = $ssh->cmd($cmd);
    print $out if $out;
    print $err if $err;
}
else {
    eval "use Term::ReadKey;";
    ReadMode('raw');
    eval "END { ReadMode('restore') };";
    $ssh->shell;
    print "Connection to $host closed.\n";
}
==================================

Is there any way to get all the fields properly.

Thank you
Pratap

Reply via email to