#!/usr/bin/perl use strict; sub making_of_list { my $ftp="c:/ftproot"; opendir (FTP, $ftp) || die $!; my @file = readdir FTP; close FTP; my $a=0; foreach (@file) { open (FILES, "+>>c:/docu/ftproot.txt") || die $!; if ("$file[$a]" =~ /txt/i) { print FILES $file[$a],"\n"; } elsif ("$file[$a]" =~ /doc/i) { print FILES $file[$a],"\n"; } elsif ("$file[$a]" =~ /mpd/i) { print FILES $file[$a],"\n"; } elsif ("$file[$a]" =~ /mta/i) { print FILES $file[$a],"\n"; }else { } $a++; close FILES; } ############################################################ sub copy_from_root { use File::Copy; my $ftplist = "c:/docu/ftproot.txt"; open (FILE, $ftplist) || die $!; my @disk = ; chomp @disk = ; $b = 0; foreach (@disk) { my $report = $disk[$b]; print $report,"\n"; if ("$report" =~ /^afinv/i) { my $reports = $report; $reports =~ s/.mta/.mpd/ig; my $truth="c:/scripts/attempt/$reports"; my $inv="c:/invoice/$reports"; my $apollo="c:/reports/$reports"; my $daym=(localtime(time()))[3]; my $afis3="c:/afis3too/$daym/$reports"; my $source = "c:/ftproot/$report"; foreach my $dest ($truth, $afis3, $apollo, $inv) { copy ($source, $dest); } unlink $source; } elsif ("$report" =~ /^csinv/i) { my $reports = $report; $reports =~ s/.mta/.mpd/ig; my $truth="c:/scripts/attempt/$reports"; my $inv="c:/invoice/$reports"; my $apollo="c:/reports/$reports"; my $daym=(localtime(time()))[3]; my $afis3="c:/afis3too/$daym/$reports"; my $source = "c:/ftproot/$report"; foreach my $dest ($truth, $afis3, $apollo, $inv) { copy ($source, $dest); } unlink $source; } elsif ("$report" =~ /^sfinv/i) { my $reports = $report; $reports =~ s/.mta/.mpd/ig; my $truth="c:/scripts/attempt/$reports"; my $inv="c:/invoice/$reports"; my $apollo="c:/reports/$reports"; my $daym=(localtime(time()))[3]; my $afis3="c:/afis3too/$daym/$reports"; my $source = "c:/ftproot/$report"; foreach my $dest ($truth, $afis3, $apollo, $inv) { copy ($source, $dest); } unlink $source; } elsif ("$report" =~ /doc/i) { my $reports = $report; $reports =~ s/doc/txt/ig; my $truth="c:/scripts/attempt/$reports"; my $apollo="c:/reports/$reports"; my $daym=(localtime(time()))[3]; my $afis3="c:/afis3too/$daym/$reports"; my $source = "c:/ftproot/$report"; foreach my $dest ($truth, $afis3, $apollo) { copy ($source, $dest); } unlink $source; } elsif ("$report" =~ /mta/i) { my $reports = $report; $reports =~ s/.mta/.mpd/ig; my $truth="c:/scripts/attempt/$reports"; my $apollo="c:/reports/$reports"; my $daym=(localtime(time()))[3]; my $afis3="c:/afis3too/$daym/$reports"; my $source = "c:/ftproot/$report"; foreach my $dest ($truth, $afis3, $apollo) { copy ($source, $dest); } unlink $source; } else { my $reports = $report; my $truth="c:/scripts/attempt/$reports"; my $listing="c:/scripts/fink.txt"; my $apollo="c:/reports/$reports"; my $daym=(localtime(time()))[3]; my $afis3="c:/afis3too/$daym/$reports"; my $source = "c:/ftproot/$report"; foreach my $dest ($truth, $afis3, $apollo) { copy ($source, $dest); } unlink $source; } my $listing="c:/scripts/fink.txt"; open (LST,"+>>$listing")or die "$!"; my $paper = sprintf("%.6s", $report); my $bbat=".bat"; my $pap=join("",$paper,$bbat); $pap =~ tr/a-z/A-Z/; print LST $pap,"\n"; close LST; $b++; } } } ############################################################ sub make_list_for_batches { my $lst = "c:/scripts/fink.txt"; open (LST, $lst) || die $!; my (@array, %hash); foreach () { push (@array, $_) unless (defined($hash{$_})); $hash{$_} = 1; }; close (LST); open (LST, ">$lst") || die $!; print LST join("", @array); close (LST); } ############################################################ sub this_gets_a_listing_of_the_batch_files { my $bats="c:/reports"; opendir (BATS, $bats) || die $!; my @bat = readdir BATS; close BATS; my $r=0; foreach (@bat) { if ("$bat[$r]" =~ /bat/i) { open (STAB, "+>>c:/scripts/bats.txt") || die $!; print STAB $bat[$r],"\n"; } $r++; } close STAB; } ############################################################ sub wow { my $batch="c:/scripts/bats.txt"; my $fink = "c:/scripts/fink.txt"; my $wow="c:/scripts/wow.txt"; open (BAT, "+$batch") or die $!; open (LST, "+$fink") or die $!; my @batch = ; my @lst = ; my $c = 0; foreach (@lst){ my $sub=$lst[$c]; my $d=0; foreach (@batch){ my $sub2 = $batch[$d]; if ("$sub2" =~ /$sub/ig){ open (WOW, "+>>$wow") or die $!; print WOW $batch[$d]; print "Working...\n"; }$d++; }$c++; } close BAT; close LST; close WOW; } ############################################################ sub run_the_batches { my $copy="c:/scripts/wow.txt"; open (COPY, "+$copy") || die $!; my @co = ; chomp @co = ; my $s=0; my $output = "c:/reports/$co[$s]"; foreach (@co) { system ($output); $s++; } } ############################################################ sub delete { my $fink = "c:/scripts/fink.txt"; my $bat = "c:/scripts/bats.txt"; my $wowo = "c:/scripts/wow.txt"; my $ftpr = "c:/docu/ftproot.txt"; open (FINK, "+>$fink") || die "$!"; open (BAT, "+>$bat") || die "$!"; open (WOW, "+>$wowo") || die "$!"; open (FTP, "+>$ftpr") || die "$!"; unlink ; unlink ; unlink ; unlink ; } # # # # # ############################################################ ############################################################ print "\n\n\n"; print " Robco Inc. Presents : \n\n\n"; print " The NEW, AMAZING, INCREDIBLE ....\n\n\n"; print " Robco Document Rotisserie!!!!!\n\n\n"; print "Just RENDER it, THEN don't REMEMBER it!!!!!\n\n"; print " It's just that easy.\n\n\n\n\n"; while (1) { my $clock = localtime; print $clock,"\n"; print "sleeping .... ZzZzZzZzZz......\n"; sleep (10); print "OK! OK! .... I'm awake! .... I'm awake\n"; ©_from_root; &make_list_for_batches; &this_gets_a_listing_of_the_batch_files; &wow; &run_the_batches; &delete; &making_of_list; } # Edited by Ovid 2001/06/15 # Shortened title from: a program to go find documents in a file then copy # them to seperate folders, delete them from the original folder, then run a # batch to process the individual files with their respected batch files