mightiemight

Thursday, September 01, 2005

PriceWatch Perl

use Env;
### From the environment Databasename $ENV{SRC_DB}
#$my_env_file = $ENV{MYENVFILE}; # passed down to called programs or batches
$my_env_file = "$ENV{CSHOME}\\PR\\$ARGV[0]"; # passed down to called programs or batches
$retry = 0;

# Legacy
#system("C:\\Perl\\bin\\perl C:\\HighGrade\\ejvPrXtrplAsys.txt");
print "Using environment $ENV{MYENVFILE} and database $ENV{SRC_DB}\n";

print "Headed into while loop\n";
while($retry < 45)
{
print "Retrying $ENV{BDIBIN}\\Xtract.bat with $ENV{MYENVFILE}\n";
system("$ENV{BDIBIN}\\Xtract.bat $ENV{MYENVFILE}");

if( -e "$ENV{SHARED_DATA}\\higr3pm.log")
{
print "Log file created for retry $retry - checking for status message\n";

open(IN, "$ENV{SHARED_DATA}\\higr3pm.log") or die("can't open $ENV{SHARED_DATA}\\higr3pm.log");
undef(@temp);
@temp = ;
close(IN);
if($temp[0] =~ /Remote\s+data\s+not\s+currently\s+available/io)
{
print " ERROR: Remote data not currently available\n";
$retry += 1;
print "Retry $retry\n";
system("net send B000E7F6659FE \"CLP EJV RETRY number $retry\"");
system("net send B000BCD2A6C90 \"CLP EJV RETRY number $retry\"");
system("net send B000BCD2B3477 \"CLP EJV RETRY number $retry\"");
system("net send B00118517642A \"CLP EJV RETRY number $retry\"");
#sleep(60);
}
if($temp[0] =~ /Unpriced\s+Securities/io)
{
print "Looks good to me - Normal message from EJV\n";
last;
}
}
if($retry >= 44)
{
system("CLP net send B000E7F6659FE \"EJV Failure to get 3PM prices\"");
system("CLP net send B000BCD2A6C90 \"EJV Failure to get 3PM prices\"");
system("CLP net send B000BCD2B3477 \"EJV Failure to get 3PM prices\"");
system("CLP net send B00118517642A \"EJV Failure to get 3PM prices\"");
exit 1;
}
} # end of retry

print "Calling C:\\Perl\\bin\\perl $ENV{BDIBIN}\\Load_3PM_Prices.txt\n";
system("C:\\Perl5\\bin\\perl $ENV{BDIBIN}\\Load_3PM_Prices.txt PR_env.bat");
if ($? > 0)
{
system("net send B000E7F6659FE \"$ENV{BDIBIN}\\Load_3PM_Prices.txt failed with empty pricing file\"");
#system("net send CLTMBSDEVTST \"$ENV{BDIBIN}\\Load_3PM_Prices.txt failed with empty pricing file\"");
exit 1;
}