#! /usr/local/perl/bin/perl -w #use strict; use GnuPG ; use Net::SMTP; use DBI; $gsDSN="dev"; $gsPassPhrase="passphrase"; $gsLogPath = "/home/autopca/ecomoper"; $gsRecipient = "RECIPIENT"; my (@gsaFields,$gsPLine,$gsALine,$gsHeader,$gsWriteLog,$gsOnlyAcctID,$gsAccount_EFile2); my ($gsPayment_File, $gsAccount_File, $gsAccount_Encrypted, $gsWhich_File,$gDBI); my $gsPath = "$gsLogPath/ecom/scripts/"; $gsLogPath .= "/ecom/tmp/"; #*******Call subs********** print "Beginning send.pl.\n"; print "******************************"; print "Beginning Payment processing.\n"; &ReadPaymentFile; #*********************************************************************************************** # ReadPaymentFile #*********************************************************************************************** #This sub reads the payment file written by Oracle and call GPG function sub ReadPaymentFile { my (@saLine,$iCount,$iPos,$sVlu,$iPos2,$saLine); #open the proper file $gsPayment_File = $gsPath . "clear.txt"; $gsPLine= ""; if (!(open (INI, "$gsPayment_File"))) { print "Payment file error: $gsPayment_File not open:$!\n"; exit(1); } #Assign the file's contents to saLine @saLine = ; close (INI); $iCount=0; #Loop through the lines of the file parsing out what we want foreach $saLine (@saLine) { chomp $saLine; if (!(length($saLine) == 80)){ print "not 80 byte:". $saLine; } $gsPLine .= $saLine."\n"; } $gsWriteLog = "Start with Payment : Sent to PGpg. "; print "Payment file read.\n"; PGpg($gsPayment_File); } #******************************************************************************************* # PGpg #******************************************************************************************* #This sub sign and encrypt payment file and call ftp function sub PGpg { my ($sFile_Name) = @_; my ($gpg); if ($gsDSN ne "dev") { #Production/QA gpg setup $gpg = new GnuPG (Homedir => "~/.gnupg", trace => $ENV{TRACING}, gnupg_path=>"/usr/local/gnupg/bin/gpg" ); } else { #Development gpg setup $gpg = new GnuPG (Homedir => "~/.gnupg", trace => $ENV{TRACING}, gnupg_path=>"/usr/bin/gpg" ); } if ($sFile_Name =~ /clear.txt/) { $gsWhich_File = $gsPath ."cipher.txt"; print "Encrypting payment file $sFile_Name with key $gsRecipient.\n"; eval {$gpg -> encrypt ( recipient => $gsRecipient, output => $gsWhich_File, armor => 1, plaintext => $sFile_Name, sign => 1, "local-user" => FF743118, passphrase => $gsPassPhrase, ); }; if ($@) { print "Errors from gpg encryption of payment file:$@\n"; exit(1); } print "Payment PGP Done. Start Transferring payment input file ($gsWhich_File).\n"; } } 1;