2009/3/4 monnappa appaiah <monnapp...@gmail.com>: > Hi, > > I tried that warn(and next) still its not logging into the next > host...........Kindly help me with this
It's a bit hard to help without seeing the errors. Do you see the warn message? Are you sure that it fails because the host is unreachable or could it be the following authentication stage? Dp. >> >> I would have thought that warn (and next) would have been exactly what >> you want. You could try this >> >> > >> > #!/usr/bin/perl -w >> > use strict; >> > use warnings; >> > >> > use Net::SSH2; >> > >> > use constant BUFLEN => 10_000; >> > >> > open my $input, '<', 'input.txt' or die $!; >> > open OUTPUT, '>', 'output.txt' or die $!; >> > >> > while (<$input>) { >> > chomp; >> > my $ssh2 = Net::SSH2->new; >> >> $ssh2->connect($_) or warn "Unable to connect host $_\n" and next; >> >> >$ssh2->auth_password('<username>','<password>'); >> > my $chan = $ssh2->channel; >> > $chan->exec('ls -al'); >> > >> > my $buf; >> > my $read = $chan->read($buf, BUFLEN); >> > die 'More than ', BUFLEN, ' characters in listing' if $read >= BUFLEN; >> > print OUTPUT "$buf\n"; >> > print OUTPUT "\n\n\n"; >> > print OUTPUT >> > >> > "----------------------------------------------------------------------------------------------------------------"; >> > $chan->exec('exit'); >> > $ssh2->disconnect; >> > >> > >> > Thanks, >> > Monnappa >> >> >> Good luck, >> Dp. >> >> -- >> To unsubscribe, e-mail: beginners-unsubscr...@perl.org >> For additional commands, e-mail: beginners-h...@perl.org >> http://learn.perl.org/ >> >> > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/