Operating System - HP-UX
1825175 Members
6365 Online
109679 Solutions
New Discussion юеВ

PERL: how can i source HP-UX Env Variables in a perl skript?

 
Maurice Skubski
Trusted Contributor

PERL: how can i source HP-UX Env Variables in a perl skript?

Hi, i have a question related to PERL under HP-UX. If i run the script, i need some Oracle Environment Parameters. If i try to source the Variables before I run the script, it seams that Perl doesn't know the Variables. So, how can i declare the Variables from a perl script, so that perl knows the parameters in its shell. any good sollution!? thanx ms
TIP: ITO was renamed to VPO. And now with Version 7 it is renamed to OVO (OpenView Operations)
4 REPLIES 4
Steve Steel
Honored Contributor

Re: PERL: how can i source HP-UX Env Variables in a perl skript?

Hi


See if you can see the env like this

#!/usr/contrib/bin/perl
foreach $key (keys %ENV){
print qq|The value of $key is $ENV{"$key"}\n|;
}

Regards

Steve Steel

Quote of the moment
-------------------
"We are drowning in information but starved for knowledge."
-- John Naisbitt
If you want truly to understand something, try to change it. (Kurt Lewin)
H.Merijn Brand (procura
Honored Contributor

Re: PERL: how can i source HP-UX Env Variables in a perl skript?

Steve's right, but you can also /set/ environment variable to be propagated to subprocesses

$ENV{ORACLE_SID} = "test";
system 'echo $ORACLE_SID'; # prints "testdb"
{ local $ENV{ORACLE_SID} = "production";
system 'echo $ORACLE_SID'; # prints "production"
}
system 'echo $ORACLE_SID'; # prints "testdb"
Enjoy, Have FUN! H.Merijn
Maurice Skubski
Trusted Contributor

Re: PERL: how can i source HP-UX Env Variables in a perl skript?

Thanx for the Ideas. That's good to define the Variables in PERL. But i have a existing File (ORACLE_ENV) which includes all the Variables and export them. It's easier for me to use this file like: . /home/oracle/ORACLE_ENV. But if i do this in Perl, no Variables are exported :( i will try to find out, which Variables are rally required to extract the Information via SQLPLUS :) ms
TIP: ITO was renamed to VPO. And now with Version 7 it is renamed to OVO (OpenView Operations)
H.Merijn Brand (procura
Honored Contributor

Re: PERL: how can i source HP-UX Env Variables in a perl skript?

open ENV, "< ORACLE_ENV" or die "ORACLE_ENV: $!";
while () {
chomp;
my ($var, $val) = split /=/ $_, 2;
$ENV{$var} = $val;
no strict 'refs';
$$var = $val;
}
close ENV or die "ORACLE_ENV: $!";
Enjoy, Have FUN! H.Merijn