Hi All,

          I have written 2 codes using "Net::SSH2" module which will connect
to remote machine (linux), execute commands and give me the output...i'm
running the script on my windows machine (win xp)......The problem is when i
run this script i don't get any ouput and i also don't get any error.....can
somebody help me wat shud i do to get the output?....I'm not sure if i'm
missing  something.    both the scripts are shown below:

----------------------------------------------------------------------------
1)

 #!/usr/bin/perl -w
use strict;
use Net::SSH2;

my $ssh2 = Net::SSH2->new();
$ssh2->connect('sys5') or die "Unable to connect host $@ \n";
$ssh2->auth_password('xyz','mypass');
my $chan = $ssh2->channel();
$chan->exec('ls -la');
while (<$chan>) {print}
-------------------------------------------------------------------------------------


2)

#!/usr/bin/perl -w
use strict;

use Net::SSH2;
my $ssh2 = Net::SSH2->new();
print "connect fail\n" unless ($ssh2->connect('sys5'));
print "password fail\n" unless ($ssh2->auth_keyboard('xyz','mypass'));

my $chan = $ssh2->channel();
$chan->shell();
print $chan "uname -a\n";
print "LINE: $_" while <$chan>;
print $chan "who\n";
print "LINE: $_" while <$chan>;
$chan->close;

--------------------------------------------------------------------

Thanks,
Monnappa

Reply via email to