I am new to perl programming i am trying to implementing a small code using Net::SSH2. I am trying to connect to one of my local machine & retrive the hostname of that machine using Net::SSH2 module, whenever i try executing the program then i just get hanged-up without any ouput.
my $ssh2 = Net::SSH2->new();
$ssh2->connect('machine') or die " Cannot connect to 219 ";
$ssh2->auth_password('username','password') or die " username/password
+ is wrong ";
print "Username/Password is correct\n";
my $chan2 = $ssh2->channel();
print $chan2 "hostname -a\n";
print "LINE : $_" while <$chan2>;
I want to know whether I am missing any points in implementing the logic.
Thanks in advance