On Thu, 26 Aug 2010 11:22:29 +0530, 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 > use Net::SSH::Perl > $host = '192.168.3.36'; > $username = 'root'; > $login_passwd = 'password'; > #$session -> close; > > #my $cmd = "ls -l"; > my $ssh = Net::SSH::Perl->new($host); $ssh->login($username, > $login_passwd); #my $arg= join '',@ARGV; > #while ($arg) { > while(<>) { > $cmd = $_; > my($stdout,$sterr, $stderr) = $ssh->cmd("$cmd"); print > "\n$stdout\n$stderr "; > print "quiting from the server " if eof; }
I just tried this code with a server and credentials of my own and it worked fine with several commands including pstree. So you have some problem specific to your configuration that needs debugging. Either the module isn't built right, you have the wrong credentials, you aren't connecting, or the remote end doesn't have the right environment, something like that. -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ http://www.informit.com/store/product.aspx?isbn=0137001274 http://www.oreillyschool.com/courses/perl1/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/