I am stuck with this issue does any one have any idea about this  ...

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

Output of the same command on the same system while accessing it using ssh
konsole
  03:37:01 up 1 day, 12:20, 11 users,  load average: 0.72, 0.52, 0.40
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
pratap   :0       -                23:00   ?xdm?  31:52   0.06s /bin/sh
/usr/bin/startkde
pratap   pts/2    :0               23:00    3.00s  0.55s  0.51s perl log.pl
pratap   pts/3    :0               23:00    4:26m  1.51s  1.50s ssh -X
pra...@192.168.3.31

==================
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