small example how to upload with ftp with threads using perl.
domains.lst -> file containing sites ie spammy.somesite.com
username in this case would be spammy.
where script is are contained folders named like "spammy.somesite.com" that matches list in domains.lst
#!/usr/bin/perl -w
use strict;
use warnings;
use threads;
use Thread::Queue;
use Net::FTP;
sub readlines {
my($filename, @lines);
($filename) = @_;
open FREEHOSTS, "<$filename";
while (my $line = <FREEHOSTS>) {
chomp($line);
push @lines,$line;
}
close FREEHOSTS;
return @lines;
}
my $ftp_password : shared;
$ftp_password = "secret";
my $DomainQueue = Thread::Queue->new;
$DomainQueue->enqueue(readlines("domains.lst"));
print $DomainQueue->pending . "\n";
my @thrs;
for(my $thr_id=0;$thr_id<6;$thr_id++) {
my $thr = threads->new(sub {
while (my $domain = $DomainQueue->dequeue_nb) {
print "starting $domain\n";
my @parts = split("\\.",$domain);
my $ftp_user = shift @parts;
next unless my $ftp = Net::FTP->new($domain, Debug => 0);
next unless $ftp->login($ftp_user,$ftp_password);
foreach my $filename (glob($domain . "/*.html")) {
$ftp->put($filename);
}
$ftp->quit();
print "done $domain\n";
}});
push(@thrs,$thr);
}
foreach my $thr (@thrs) {
$thr->join;
}