Ok , all file contents and code are below, this is a sort of complicated
issue. I have a config file with customer static information , a couple of
modules, and a script. The basis of the problem is that in the config file
there is an sql query that has some variables in it. The script calls one
module to get the information , then another to use the information. The
problem is that the variables in the config are not being translated into
there actual values before they get used.
Any fresh ideas would be greatly appreciated. If more information is
needed please contact me directly and I will provide what I can.
*****Script Here*****
use strict;
unshift (@INC, "/home/aup/scripts/development/modules/");
use DSLLookup;
my @customerResults = DSLLookup::GetCustomer('vzd');
my $oraResults =
DSLLookup::GetInfo(@customerResults,'192.168.102.112','TARJ 3-PTO 2');
***** End Script *****
***** Start DSLLookup Module *****
use DBI;
use Config::IniFiles;
# Declare global variables.
our $DB;
our $HOST;
our $TABLE;
our $SID;
our $count;
our $row;
our $total;
our $username;
our $password;
our $ORAPORT;
our $customer;
our $QUERY;
sub GetCustomer {
my($customer) = @_;
my $cfg = new Config::IniFiles( -file =>
"/home/aup/scripts/development/configs/$customer/customer.cfg");
$HOST = $cfg->val('AUP', 'host');
$DB = $cfg->val('AUP', 'db');
$SID = $cfg->val('AUP', 'sid');
$username = $cfg->val('AUP', 'username');
$password = $cfg->val('AUP', 'password');
$ORAPORT = $cfg->val('AUP', 'oraport');
$QUERY = $cfg->val('AUP', 'query');
return ($customer,$HOST,$DB,$SID,$username,$password,$ORAPORT,$QUERY);
} # End GetCustomer
sub GetInfo {
# pre declare some global variables. #
my
($affiliate,$HOST,$DB,$SID,$username,$password,$ORAPORT,$QUERY,$ip_address
,$dslam) = @_;
# Connect to the database.
my $dbh =
DBI->connect("DBI:Oracle:database=$DB;host=$HOST;sid=$SID;port=$ORAPORT","
$username","$password", {'RaiseError' => 1});
# Now retrieve data from the table.
my $sth = $dbh->prepare(qq{$QUERY});
#print "DEBUG: $QUERY\n";
$sth->execute;
while ( my @row = $sth->fetchrow_array) {
$ip_address = "$row[0]\n";
my $node_address = "$row[1]\n";
my $last_nm = "$row[2]\n";
my $first_name;
if(!$row[3]){
$first_name = "\n";
}else{
$first_name = "$row[3]\n";
}
my $related_pon = "$row[4]\n";
my $addr_lin1 = "$row[5]\n";
print "IP: $ip_address DSLAM: $node_address Last Name: $last_nm
First Name: $first_name Phone: $related_pon Address: $addr_lin1";
}
} ## End GetInfo
**** End DSLLookup Module *****
**** Customer Config File Start *****
[AUP]
host=192.168.2.39
db=mydb
sid=mydb_prod
username=myname
password=mypass
oraport=1525
query= <<END
SELECT N.IP_ADDRESS,
P.NODE_ADDRESS,
SO.LAST_NM,
SO.FIRST_NAME,
SR.RELATED_PON,
AD.ADDR_LN1
FROM NETWORK_NODE N,
EQUIPMENT E,
MOUNTING_POSITION MP,
PORT_ADDRESS P,
SERVICE_REQUEST_CIRCUIT S,
SERV_ORD SO,
SERV_REQ SR,
EQUIPMENT E1,
CUST_ACCt_ADDR CAA,
ADDRESS AD
WHERE N.NETWORK_NODE_ID = E.NETWORK_NODE_ID
AND E.EQUIPMENT_ID = MP.EQUIPMENT_ID
AND E1.EQUIPMENT_ID = MP.EQUIPMENT_ID_2
AND E1.EQUIPMENT_ID = P.EQUIPMENT_ID
AND P.CIRCUIT_DESIGN_ID = S.CIRCUIT_DESIGN_ID
AND SO.DOCUMENT_NUMBER = S.DOCUMENT_NUMBER
AND SR.DOCUMENT_NUMBER = S.DOCUMENT_NUMBER
AND SR.CUST_ACCT_ID = CAA.CUST_ACCT_ID
AND CAA.ADDRESS_ID = AD.ADDRESS_ID
AND P.NODE_ADDRESS = $dslam
AND N.IP_ADDRESS = $ip_address
END
***** Customer Config File End ******
Chris Hood
Investigator Verizon Global Security Operations Center