-
Notifications
You must be signed in to change notification settings - Fork 0
/
startMasterEngine.pl
78 lines (72 loc) · 2.47 KB
/
startMasterEngine.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/perl -w
use strict;
use Time::HiRes qw(gettimeofday);
use Cwd;
my $timeStamp = int (gettimeofday * 1000000000);
my @variableArray;
open (LOG, "+>logs\/log_startMasterEngine.txt");
#change the extension here
my $dir = getcwd;
my $workToDoDir = $dir . '/workToDo/';
my $doneWorkToDoDir = $dir . '/doneWorkToDo/';
my @files = <workToDo/*parse>;
my @files1 = sort @files;
@files = @files1;
my $theFileName;
my $variableStringForExec = "";
print LOG "Starting to look at all files. There are $#files total files\n";
foreach $theFileName (@files) {
my $timeStampFile = 99999999999;
$variableStringForExec = "";
print LOG "found $theFileName\n";
my $fileNameWithoutFolderExtension;
if ($theFileName =~ /workToDo\/(.*\.parse)$/) {
$fileNameWithoutFolderExtension = $1;
if ($theFileName =~ /workToDo\/(\d+).*\.parse$/) {
$timeStampFile = $1;
}
}
if ($timeStamp >= $timeStampFile) {
print LOG "found $theFileName and its timestamp is less than this startTime\n";
#print "\n" . $theFileName . "\n";
open (INPUT, "$theFileName");
my @lines = <INPUT>;
if ($#lines > 0) {
chomp (@lines);
my $theLinesName;
my $lineScroll = 0;
my $whichArrayWeAreOn = -1;
foreach $theLinesName (@lines) {
if ($theLinesName =~ /iiiiiiiiBeginNewVariableiiiiiiiiiii/) {
$variableStringForExec = "$variableStringForExec \'";
$whichArrayWeAreOn++;
$variableArray[$whichArrayWeAreOn] = "";
}
else {
$variableStringForExec = $variableStringForExec . $theLinesName . "\n";
#$variableArray[$whichArrayWeAreOn] = $variableArray[$whichArrayWeAreOn] . $theLinesName;
if ($lineScroll < $#lines) {
if ($lines[$lineScroll+1] =~ /iiiiiiiiBeginNewVariableiiiiiiiiiii/) {
$variableStringForExec = $variableStringForExec . "\' ";
#$variableArray[$whichArrayWeAreOn] = $variableArray[$whichArrayWeAreOn] . "\'\n";
}
}
}
$lineScroll++;
#print "*" . $theLinesName . "\n";
}
print LOG "\n\n\n\n" . $theFileName . "\n";
my $variables;
$variableStringForExec = $variableStringForExec . "\'\n";
#put in the perl file in here
print LOG "going into converted_masterEngine variables:<$variableStringForExec>\n";
system("perl converted_masterEngineWithDBI_CLI4.pl $variableStringForExec");
}
close (INPUT);
system ("mv $theFileName $doneWorkToDoDir" . "$fileNameWithoutFolderExtension");
}
else {
print LOG "the file was newer than the beginning of this script start time\n";
}
}
close (LOG);