Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # For use in Archive Team Friendster project
- # A Perl utility for use with bff.sh. This will launch as many instances
- # of bff.sh as you want, each handling as many profile IDs as you want.
- # It will just launch the specified number of instances, then quit. The rest
- # (monitoring them, launching new ones once they're done, etc) is up to you.
- #
- # Features:
- # Quick usage guide: $ ./invoker.pl help
- # Specify the starting ID, range, and number of processes as command line
- # arguments. The order is $ ./invoker.pl [start] [range] [instances], where
- # "start" is the starting ID, "range" is the number of IDs per process, and
- # "instances" is the number of instances to launch.
- # Each instance uses a different cookie file and logs to its own log
- # file.
- # You can do a clean stop of all the instances by creating a file named
- # "STOP" in their directory (just like with listerine). Each instance will stop
- # after finishing its current profile.
- # Because they're launched in the background, you might want a way to
- # monitor their progress. That's why I have them log each finished download to
- # "progress.txt", in the format "[instancenumber]: [lastID]". To show a quick
- # summary of the latest, I wrote summary.pl (http://pastebin.com/ADT7k4DX).
- # (Don't worry if some instances don't show up at first. They only make an
- # entry after their first success.)
- # You can also use this to just write the bash script file that will
- # launch all the instances. Just add "-p" after the rest of the arguments.
- # The script will be called "startem.sh".
- my $scriptfile = "startem.sh";
- my $configfile = "config.txt";
- open FILEOUT, "+>", $scriptfile or
- die "Error: could not open output file $scriptfile: $!";
- open CONFIG, "+>", $configfile or
- die "Error: could not open output file $configfile: $!";
- # default values
- my $start = 3050001;
- my $step = 100;
- my $instances = 5;
- my $print = 1;
- # gettin' arguments
- my $args = @ARGV;
- if ($ARGV[0] eq "help") {
- print "use: ./invoker.pl [start] [range] [instances] [-p]\n" .
- "start = starting id\n" .
- "range = size of range handled by each instance\n" .
- "instances = number of instances to invoke\n" .
- "-p = just print the shell script; don't run it\n";
- exit 0;
- }
- if ($args >= 1) {
- $start = shift @ARGV;
- }
- if ($args >= 2) {
- $step = shift @ARGV;
- }
- if ($args >= 3) {
- $instances = shift @ARGV;
- }
- if ($args >= 4) {
- $print = shift @ARGV;
- }
- my $end = $start + $step - 1;
- my $command;
- # Compiles all the variables into the shell command, then prints the command
- # to a shell script file to be run later. I know I should be calling it
- # directly from here, but perl's interpretation of shell commands is
- # surprisingly annoying. Plus, this way I can call it a feature that it will
- # produce the intermediate shell script for you!
- # Also, this prints information about the starting configuration of the
- # instances into a file for use by summary.pl in displaying progress percentage
- print FILEOUT "#!/bin/bash\n";
- for ($instance = 1; $instance <= $instances; $instance++) {
- $command = "(for i in {$start..$end}; do bash bff.sh \$i " .
- "cookie$instance.txt >> log$instance.txt; " .
- "echo \"$instance: \$i\" >> progress.txt; " .
- "if [ -e STOP ]; then exit 0; fi; done;) &\n";
- print FILEOUT $command;
- printf CONFIG "$instance: $start\n";
- $start += $step;
- $end += $step;
- }
- close FILEOUT;
- close CONFIG;
- # Run the shell script produced above
- if (!$print) {
- exec "./$scriptfile";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement