SHARE
TWEET

Friendster tool: invoker.pl

Qwerty0 May 7th, 2011 182 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2. # For use in Archive Team Friendster project
  3. #       A Perl utility for use with bff.sh. This will launch as many instances
  4. # of bff.sh as you want, each handling as many profile IDs as you want.
  5. # It will just launch the specified number of instances, then quit. The rest
  6. # (monitoring them, launching new ones once they're done, etc) is up to you.
  7. #
  8. # Features:
  9. #       Quick usage guide: $ ./invoker.pl help
  10. #       Specify the starting ID, range, and number of processes as command line
  11. # arguments. The order is $ ./invoker.pl [start] [range] [instances], where
  12. # "start" is the starting ID, "range" is the number of IDs per process, and
  13. # "instances" is the number of instances to launch.
  14. #       Each instance uses a different cookie file and logs to its own log
  15. # file.
  16. #       You can do a clean stop of all the instances by creating a file named
  17. # "STOP" in their directory (just like with listerine). Each instance will stop
  18. # after finishing its current profile.
  19. #       Because they're launched in the background, you might want a way to
  20. # monitor their progress. That's why I have them log each finished download to
  21. # "progress.txt", in the format "[instancenumber]: [lastID]". To show a quick
  22. # summary of the latest, I wrote summary.pl (http://pastebin.com/ADT7k4DX).
  23. # (Don't worry if some instances don't show up at first. They only make an
  24. # entry after their first success.)
  25. #       You can also use this to just write the bash script file that will
  26. # launch all the instances. Just add "-p" after the rest of the arguments.
  27. # The script will be called "startem.sh".
  28.  
  29. my $scriptfile = "startem.sh";
  30. my $configfile = "config.txt";
  31. open FILEOUT, "+>", $scriptfile or
  32.         die "Error: could not open output file $scriptfile: $!";
  33. open CONFIG, "+>", $configfile or
  34.         die "Error: could not open output file $configfile: $!";
  35.  
  36. # default values
  37. my $start = 3050001;
  38. my $step = 100;
  39. my $instances = 5;
  40. my $print = 1;
  41.  
  42. # gettin' arguments
  43. my $args = @ARGV;
  44. if ($ARGV[0] eq "help") {
  45.         print "use: ./invoker.pl [start] [range] [instances] [-p]\n" .
  46.                 "start     = starting id\n" .
  47.                 "range     = size of range handled by each instance\n" .
  48.                 "instances = number of instances to invoke\n" .
  49.                 "-p = just print the shell script; don't run it\n";
  50.         exit 0;
  51. }
  52.  
  53. if ($args >= 1) {
  54.         $start = shift @ARGV;
  55. }
  56. if ($args >= 2) {
  57.         $step = shift @ARGV;
  58. }
  59. if ($args >= 3) {
  60.         $instances = shift @ARGV;
  61. }
  62. if ($args >= 4) {
  63.         $print = shift @ARGV;
  64. }
  65.  
  66. my $end = $start + $step - 1;
  67. my $command;
  68.  
  69. # Compiles all the variables into the shell command, then prints the command
  70. # to a shell script file to be run later. I know I should be calling it
  71. # directly from here, but perl's interpretation of shell commands is
  72. # surprisingly annoying. Plus, this way I can call it a feature that it will
  73. # produce the intermediate shell script for you!
  74. # Also, this prints information about the starting configuration of the
  75. # instances into a file for use by summary.pl in displaying progress percentage
  76. print FILEOUT "#!/bin/bash\n";
  77. for ($instance = 1; $instance <= $instances; $instance++) {
  78.         $command = "(for i in {$start..$end}; do bash bff.sh \$i " .
  79.                 "cookie$instance.txt >> log$instance.txt; " .
  80.                 "echo \"$instance: \$i\" >> progress.txt; " .
  81.                 "if [ -e STOP ]; then exit 0; fi; done;) &\n";
  82.         print FILEOUT $command;
  83.         printf CONFIG "$instance: $start\n";
  84.         $start += $step;
  85.         $end += $step;
  86. }
  87.  
  88. close FILEOUT;
  89. close CONFIG;
  90.  
  91. # Run the shell script produced above
  92. if (!$print) {
  93.         exec "./$scriptfile";
  94. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top