The following works for me on a Windows XP box talking to a Solaris server:-
BEGIN { if (($^O eq 'MSWin32') or ($^O =~ /cygwin/i)) { # $ENV{ORACLE_HOME} = q{C:/Oracle/Ora81}; # But Oracle::DBD will find it from the Windows registry anyway } else { $ENV{ORACLE_HOME} = q{/path/to/product/8.1.7}; } $host = q{BLAH.BLAH.COM}; ..... eval { ... $dbh = DBI->connect("dbi:Oracle:$host", $uid, $pw) or die qq{Unable to connect to $host:<br/>$DBI::errstr\n}; ... There is some Oracle s/w pre-installed on my XP box about which I know nothing except that I can see the magic string BLAH.BLAH.COM inside somewhere. I've never tried disconnecting and reconnecting to some other d-b. HTH, GStC. -----Original Message----- From: Jason Wozniak [mailto:[EMAIL PROTECTED] Sent: Monday, February 21, 2005 4:15 PM To: beginners@perl.org Subject: RE: Environment variables That's what I thought, but it doesn't work, which is why I tried system. The below code: use DBI; my $database; #my $address = "[EMAIL PROTECTED]"; my $address = "[EMAIL PROTECTED]"; my %attr; my $dbh; open MAIL, "|mail $address"; open DBFILE, "</u01/app/oracle/check_list.txt"; while (<DBFILE>) { $ENV{ORACLE_SID} == chomp($_); print "$ENV{ORACLE_SID}\n"; $dbh = DBI->connect( "dbi:Oracle:$database", "", "", \%attr) or print MAIL "Could not connect to database: $ENV{ORACLE_SID} $DBI::errstr\n"; } close MAIL; produces the following output: P01 P01 P01 P01 P01 The file /u01/app/oracle/check_list.txt contains several different sids, and if I print $_ it is reading them in. -----Original Message----- From: Scott Pham [mailto:[EMAIL PROTECTED] Sent: Monday, February 21, 2005 4:05 PM To: Jason Wozniak Subject: Re: Environment variables You want use ENV hash (%ENV). The reason why system or `` doesn't work is due to them being forked off. $ENV{ORACLE_SID} = "whateva"; will do it for you. On Mon, 21 Feb 2005 15:51:06 -0500, Jason Wozniak <[EMAIL PROTECTED]> wrote: > 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; > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>