CyBorg1958
Programmer
Hi!
My script is triggered by the formatting process in our billing system, and when that happens it wants to use STDIN and -OUT as the in- and outdata. When I test the script I run it in another folder, from the command line : perl scriptname.pl. What I want to do is have the script know where it is, and use the appropriate in- and outdata streams accordingly: Regular files in the testing location, standard in/out in production. Running it from the command line in the prod folder it works fine, but when triggered from the billing process it won't. This is what it looks like:
use Cwd;
my $WorkingDirectory = getcwd();
my $in_file = $WorkingDirectory.'/INDATA.GMF';
my $out_file = $WorkingDirectory.'/UTDATA.GMF';
my $log_file = $WorkingDirectory.'/PreProcessBillTags.log';
open (LOGFILE, "+>$log_file") or die "can't open $log_file $!";
if ($WorkingDirectory =~ /customscripts$/i)
{
open (BILLFILE, "-") or die "Cannot read from standard input BILLFILE";
open (BILLOUTPUT, ">-") or die "Cannot write to standard output BILLOUTPUT";
}
else
{
open (BILLFILE, "$in_file") or die "Cannot read from input file $in_file";
open (BILLOUTPUT, "+>$out_file") or die "Cannot write to output file $out_file";
}
My script is triggered by the formatting process in our billing system, and when that happens it wants to use STDIN and -OUT as the in- and outdata. When I test the script I run it in another folder, from the command line : perl scriptname.pl. What I want to do is have the script know where it is, and use the appropriate in- and outdata streams accordingly: Regular files in the testing location, standard in/out in production. Running it from the command line in the prod folder it works fine, but when triggered from the billing process it won't. This is what it looks like:
use Cwd;
my $WorkingDirectory = getcwd();
my $in_file = $WorkingDirectory.'/INDATA.GMF';
my $out_file = $WorkingDirectory.'/UTDATA.GMF';
my $log_file = $WorkingDirectory.'/PreProcessBillTags.log';
open (LOGFILE, "+>$log_file") or die "can't open $log_file $!";
if ($WorkingDirectory =~ /customscripts$/i)
{
open (BILLFILE, "-") or die "Cannot read from standard input BILLFILE";
open (BILLOUTPUT, ">-") or die "Cannot write to standard output BILLOUTPUT";
}
else
{
open (BILLFILE, "$in_file") or die "Cannot read from input file $in_file";
open (BILLOUTPUT, "+>$out_file") or die "Cannot write to output file $out_file";
}