#!/usr/bin/perl use strict; use Getopt::Std; # name: filespam # author: ap0calypse ( ap0calypse@agitatio.org ) # version: 0.1 ( 2008-06-03 ) # license: DO WHATEVER YOU WANT! # purpose: creates as many empty spam-files as you specify # examples: # filespam -n 1000 -d /tmp/test # - creates 1000 empty spamfiles in /tmp/test # (/tmp/test MUST exist) our (%args, $num_files, $dest_dir); our $VERSION = "0.1"; getopts("n:d:", \%args); if ($args{'n'}) { if ($args{'n'} =~ m/^\d+$/) { $num_files = $args{'n'}; } else { print "you specified an invalid amount of spam-files\n"; exit 3; } } else { print "you didn't specify the amount of spam-files!\n"; &usage; exit 1; } if ($args{'d'}) { if (-d $args{'d'} and -w $args{'d'}) { $dest_dir = $args{'d'}; } else { print "you specified an invalid/not writeable directory\n"; exit 4; } } else { print "you didn't specify the destination directory!\n"; &usage; exit 2; } for (1 .. $num_files) { my @chars = ("A" .. "Z", "a" .. "z", 0 .. 9, qw( ! @ $ % & )); my $randomstring = join ("", @chars[map {rand @chars} (1 .. 10)] ); open TMPFILE, "> $dest_dir/$randomstring\_$_" or die "error: $!"; close TMPFILE; } print "$num_files spam-files created in $dest_dir\n"; sub usage { print << "EOUSAGE"; USAGE: ------ filespame -n NUM -d DIR EXAMPLE: -------- filespam -n 1000 -d /tmp/test - creates 1000 empty spamfiles in /tmp/test (/tmp/test MUST exist) EOUSAGE }