0: #!/usr/bin/perl
1: use strict;
2:
3: sub making_of_list {
4:
5: my $ftp="c:/ftproot";
6: opendir (FTP, $ftp) || die $!;
7: my @file = readdir FTP;
8: close FTP;
9: my $a=0;
10: foreach (@file) {
11:
12: open (FILES, "+>>c:/docu/ftproot.txt") || die $!;
13: if ("$file[$a]" =~ /txt/i) {
14: print FILES $file[$a],"\n";
15: } elsif ("$file[$a]" =~ /doc/i) {
16: print FILES $file[$a],"\n";
17: } elsif ("$file[$a]" =~ /mpd/i) {
18: print FILES $file[$a],"\n";
19: } elsif ("$file[$a]" =~ /mta/i) {
20: print FILES $file[$a],"\n";
21: }else {
22: }
23: $a++;
24: close FILES;
25: }
26:
27: ############################################################
28:
29: sub copy_from_root {
30:
31: use File::Copy;
32: my $ftplist = "c:/docu/ftproot.txt";
33: open (FILE, $ftplist) || die $!;
34: my @disk = <FILE>;
35: chomp @disk = <FILE>;
36: $b = 0;
37: foreach (@disk) {
38: my $report = $disk[$b];
39: print $report,"\n";
40: if ("$report" =~ /^afinv/i) {
41: my $reports = $report;
42: $reports =~ s/.mta/.mpd/ig;
43: my $truth="c:/scripts/attempt/$reports";
44: my $inv="c:/invoice/$reports";
45: my $apollo="c:/reports/$reports";
46: my $daym=(localtime(time()))[3];
47: my $afis3="c:/afis3too/$daym/$reports";
48: my $source = "c:/ftproot/$report";
49: foreach my $dest ($truth, $afis3, $apollo, $inv) {
50: copy ($source, $dest);
51: }
52: unlink $source;
53: } elsif ("$report" =~ /^csinv/i) {
54: my $reports = $report;
55: $reports =~ s/.mta/.mpd/ig;
56: my $truth="c:/scripts/attempt/$reports";
57: my $inv="c:/invoice/$reports";
58: my $apollo="c:/reports/$reports";
59: my $daym=(localtime(time()))[3];
60: my $afis3="c:/afis3too/$daym/$reports";
61: my $source = "c:/ftproot/$report";
62: foreach my $dest ($truth, $afis3, $apollo, $inv) {
63: copy ($source, $dest);
64: }
65: unlink $source;
66: } elsif ("$report" =~ /^sfinv/i) {
67: my $reports = $report;
68: $reports =~ s/.mta/.mpd/ig;
69: my $truth="c:/scripts/attempt/$reports";
70: my $inv="c:/invoice/$reports";
71: my $apollo="c:/reports/$reports";
72: my $daym=(localtime(time()))[3];
73: my $afis3="c:/afis3too/$daym/$reports";
74: my $source = "c:/ftproot/$report";
75: foreach my $dest ($truth, $afis3, $apollo, $inv) {
76: copy ($source, $dest);
77: }
78: unlink $source;
79: } elsif ("$report" =~ /doc/i) {
80: my $reports = $report;
81: $reports =~ s/doc/txt/ig;
82: my $truth="c:/scripts/attempt/$reports";
83: my $apollo="c:/reports/$reports";
84: my $daym=(localtime(time()))[3];
85: my $afis3="c:/afis3too/$daym/$reports";
86: my $source = "c:/ftproot/$report";
87: foreach my $dest ($truth, $afis3, $apollo) {
88: copy ($source, $dest);
89: }
90: unlink $source;
91: } elsif ("$report" =~ /mta/i) {
92: my $reports = $report;
93: $reports =~ s/.mta/.mpd/ig;
94: my $truth="c:/scripts/attempt/$reports";
95: my $apollo="c:/reports/$reports";
96: my $daym=(localtime(time()))[3];
97: my $afis3="c:/afis3too/$daym/$reports";
98: my $source = "c:/ftproot/$report";
99: foreach my $dest ($truth, $afis3, $apollo) {
100: copy ($source, $dest);
101: }
102: unlink $source;
103: } else {
104: my $reports = $report;
105: my $truth="c:/scripts/attempt/$reports";
106: my $listing="c:/scripts/fink.txt";
107: my $apollo="c:/reports/$reports";
108: my $daym=(localtime(time()))[3];
109: my $afis3="c:/afis3too/$daym/$reports";
110: my $source = "c:/ftproot/$report";
111: foreach my $dest ($truth, $afis3, $apollo) {
112: copy ($source, $dest);
113: }
114: unlink $source;
115: }
116: my $listing="c:/scripts/fink.txt";
117: open (LST,"+>>$listing")or die "$!";
118: my $paper = sprintf("%.6s", $report);
119: my $bbat=".bat";
120: my $pap=join("",$paper,$bbat);
121: $pap =~ tr/a-z/A-Z/;
122: print LST $pap,"\n";
123: close LST;
124: $b++;
125: }
126: }
127: }
128: ############################################################
129:
130: sub make_list_for_batches {
131:
132: my $lst = "c:/scripts/fink.txt";
133:
134: open (LST, $lst) || die $!;
135: my (@array, %hash);
136: foreach (<LST>) {
137: push (@array, $_) unless (defined($hash{$_}));
138: $hash{$_} = 1;
139: };
140: close (LST);
141: open (LST, ">$lst") || die $!;
142: print LST join("", @array);
143: close (LST);
144: }
145:
146: ############################################################
147:
148: sub this_gets_a_listing_of_the_batch_files {
149:
150: my $bats="c:/reports";
151: opendir (BATS, $bats) || die $!;
152: my @bat = readdir BATS;
153: close BATS;
154: my $r=0;
155: foreach (@bat) {
156: if ("$bat[$r]" =~ /bat/i) {
157: open (STAB, "+>>c:/scripts/bats.txt") || die $!;
158: print STAB $bat[$r],"\n";
159: }
160: $r++;
161: }
162: close STAB;
163: }
164:
165: ############################################################
166:
167: sub wow {
168:
169: my $batch="c:/scripts/bats.txt";
170: my $fink = "c:/scripts/fink.txt";
171: my $wow="c:/scripts/wow.txt";
172: open (BAT, "+$batch") or die $!;
173: open (LST, "+$fink") or die $!;
174: my @batch = <BAT>;
175: my @lst = <LST>;
176: my $c = 0;
177: foreach (@lst){
178: my $sub=$lst[$c];
179: my $d=0;
180: foreach (@batch){
181: my $sub2 = $batch[$d];
182: if ("$sub2" =~ /$sub/ig){
183: open (WOW, "+>>$wow") or die $!;
184: print WOW $batch[$d];
185: print "Working...\n";
186: }$d++;
187: }$c++;
188: }
189: close BAT;
190: close LST;
191: close WOW;
192: }
193:
194: ############################################################
195:
196: sub run_the_batches {
197:
198: my $copy="c:/scripts/wow.txt";
199: open (COPY, "+$copy") || die $!;
200: my @co = <COPY>;
201: chomp @co = <COPY>;
202: my $s=0;
203: my $output = "c:/reports/$co[$s]";
204: foreach (@co) {
205: system ($output);
206: $s++;
207: }
208:
209: }
210:
211: ############################################################
212:
213: sub delete {
214:
215: my $fink = "c:/scripts/fink.txt";
216: my $bat = "c:/scripts/bats.txt";
217: my $wowo = "c:/scripts/wow.txt";
218: my $ftpr = "c:/docu/ftproot.txt";
219:
220: open (FINK, "+>$fink") || die "$!";
221: open (BAT, "+>$bat") || die "$!";
222: open (WOW, "+>$wowo") || die "$!";
223: open (FTP, "+>$ftpr") || die "$!";
224:
225: unlink <FINK>;
226: unlink <BAT>;
227: unlink <WOW>;
228: unlink <FTP>;
229:
230: }
231:
232: #
233: #
234: #
235: #
236: #
237: ############################################################
238:
239: ############################################################
240:
241:
242: print "\n\n\n";
243: print " Robco Inc. Presents : \n\n\n";
244: print " The NEW, AMAZING, INCREDIBLE ....\n\n\n";
245: print " Robco Document Rotisserie!!!!!\n\n\n";
246: print "Just RENDER it, THEN don't REMEMBER it!!!!!\n\n";
247: print " It's just that easy.\n\n\n\n\n";
248:
249: while (1) {
250:
251: my $clock = localtime;
252: print $clock,"\n";
253: print "sleeping .... ZzZzZzZzZz......\n";
254: sleep (10);
255: print "OK! OK! .... I'm awake! .... I'm awake\n";
256: ©_from_root;
257: &make_list_for_batches;
258: &this_gets_a_listing_of_the_batch_files;
259: &wow;
260: &run_the_batches;
261: &delete;
262: &making_of_list;
263: }
264:
265: # Edited by Ovid 2001/06/15
266: # Shortened title from: a program to go find documents in a file then copy
267: # them to seperate folders, delete them from the original folder, then run a
268: # batch to process the individual files with their respected batch files In reply to Document maintenance script by blacksmith
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |