Hi Pratap,

a few comments on your code. I'm not sure they will help with anything, but 
they are still appropriate.

On Thursday 26 August 2010 08:52:29 S Pratap Singh wrote:
> Here is my code which logs in and performs some task but it does not show
> the output of top and pstree command what would i do to get the output of
> these commands along with vmstat and iostat
> 
> #!/usr/bin/perl -w

Add "use strict;" and "use warnings;" (though some people believe that "-w" is 
better than "use warnings;" - but it's no substitute to "use strict;").

> use Net::SSH::Perl
> $host = '192.168.3.36';

my $host = '192.168.3.36'; ("use strict;" will catch that).

> $username = 'root';
> $login_passwd = 'password';
> #$session -> close;

Why do you have commented-out code here? Please clean it up.

> 
> #my $cmd = "ls -l";
> my $ssh = Net::SSH::Perl->new($host);
> $ssh->login($username, $login_passwd);
> #my $arg= join '',@ARGV;
> #while ($arg) {

You need to split your code into paragraphs with empty lines in between.

> while(<>) {
> $cmd = $_;

This is better written as:

[code]
while (my $cmd = <>)
[/code]

And you probably want chomp.

> my($stdout,$sterr, $stderr) = $ssh->cmd("$cmd");

What is $sterr? And you seem to have both that and $stderr.

> print "\n$stdout\n$stderr       ";
> print "quiting from the server " if eof;

You've misspelled "quitting" and better put a filehandle in eof().

Regards,

        Shlomi Fish

> }
> 
> Thanks for all the responses  ..
> 
> Regards,
> Pratap

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
List of Portability Libraries - http://shlom.in/port-libs

God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to