Hello,

            I'm trying to write a paging script that connects to several
databases in succession, and was attempting to write the script such
that I would not have to hard code any user names, or passwords, by
using an externally identified user.

 

I can connect to the first database in the list ok, but I can't figure
out how to change my ORACLE_SID environment variable, so it simply
reconnects to the same database each time through the loop for every sid
in the file.  I tried setting $ENV{ORACLE_SID} to no effect.  I even
tried using:

 

System("export ORACLE_SID = $_");  and verified $_ was being read in
correctly, as seen below.  Is there no way to modify your shell
environment from within a perl program?  I saw a module called
Env-Bash-0.04, but it doesn't seem to say if you can update an
environment variable, it just makes sure you can access them all.

 

use DBI;

 

my $database;

my $address = "[EMAIL PROTECTED]";

my %attr;

my $dbh;

open MAIL, "|mail $address";

open DBFILE, "</u01/app/oracle/check_list.txt";

 

while (<DBFILE>) {

system("export ORACLE_SID = $_");

$dbh = DBI->connect( "dbi:Oracle:$database", "", "", \%attr)

        or print MAIL "Could not connect to database: $ENV{ORACLE_SID}
$DBI::errstr\n";

}

close MAIL;

 

 

Reply via email to