develooper Front page | perl.dbi.users | Postings from February 2001

DBI::Oracle problem

Thread Next
From:
David Sherrington - Enterprise Services- Data Management Systems Engineer
Date:
February 7, 2001 03:53
Subject:
DBI::Oracle problem
Message ID:
200102071153.LAA16932@cby-wts.UK.Sun.COM
Hello,

I've have a problem with connecting to an Oracle database using DBI under Unix.

Basically, I have the Database user passwords in a unix flat file, which I read 
into the perl script setting a local variable. The Oracle database name and the 
User name a passed to the perl script as arguements.

When I try to connect to the database I get the Oracle invalid user/password 
error. I have investigated this and know that the Database name and User name 
are being picked up correctly, but for some reason the DBI module is ignoring 
the contents of the password variable, even though it is set correctly.

Now, if I reset the password variable (ie: hard code the password into the perl 
script) just before I try connecting to the database it works!!

If anybody has any Ideas, I would be most grateful.

Below is the code I am using:

Many thanks.

David

----------------------------------------------------------------------
#!/usr/local/bin/perl -w
##########################################
# Include DBI 
##########################################
eval '$dbh::safe = 1'       if $] >=5;
eval 'use DBI; 1' || die $@ if $] >=5;
####################################################################
#Check that three arguements have been passed and set variables
####################################################################
if (scalar(@ARGV) != 3) {
   print "ERROR: Incorrect number of arguements passed. \n";
   print "ERROR: Specify User, SID and PWD file. \n";
   exit;
}
$dbuser = $ARGV[0];
$dbname = $ARGV[1];
$pwd    = $ARGV[2];
$dbuser_orig = "$dbuser";
##################################################
# Open/retreive password from flat file
##################################################
open(USERPWD,"$pwd") || die "Could not open password file!";
$dbpass =  <USERPWD>;
close(USERPWD);
######################################################
# Connect/logon to database
######################################################
#
$dbh = DBI->connect("dbi:Oracle:$dbname","$dbuser","$dbpass", "")
      || die "$DBI::$errstr\n ";

-----------------------------------------------------------------------
 


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About