Env::Sourced - false error
------_=_NextPart_001_01CB2EE3.45DFDBC4
Content-Type: text/plain;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable
Hi list,
Maybe one of you has a clue why I get a false error message when using
Env::Sourced. My (test-)script is as follows:
#!/usr/bin/perl -w
use strict;
use warnings;
require Env::Sourced; # "require" necessary in main programme, just not
changed for testing
my $w_conf =3D $ENV{'W_UMG_CONFIG_PFAD'};
my $oraenv;
my $orapat =3D '9208';
print "Environment BEFORE:\n", `env |grep ORA`, "\n";
if ( $orapat ne 'D' ) {
$oraenv =3D "$w_conf/ora$orapat.env"; # coalesce path + filename
print "OraEnv: $oraenv\n"; # check absolute file name
Env::Sourced->import($oraenv) or warn "Fehler beim Setzen des
Oracle-Environments: $!\n"; # set environment
}
print "\nEnvironment AFTER:\n", `env |grep ORA`, "\n";
BUT I get the following output:
oracle:/opt/data/magna/wartung/work/nora>./test.pl
Environment BEFORE:
ORACLE_BASE=3D/opt/app/oracle
ORACLE_SID=3D
ORA_NLS=3D/opt/app/oracle/product/9.2/ocommon/nls/admin/data
ORACLE_TERM=3Dvt220
ORA_NLS32=3D/opt/app/oracle/product/9.2/ocommon/nls/admin/da ta
ORA_NLS33=3D/opt/app/oracle/product/9.2/ocommon/nls/admin/da ta
ORADATA=3D/opt/app/oracle/oradata1
ORACLE_HOME=3D/opt/app/oracle/product/9.2
OraEnv: /opt/data/magna/umgebungen/config/ora9208.env
Fehler beim Setzen des Oracle-Environments:
Environment AFTER:
ORACLE_BASE=3D/opt/app/oracle
ORACLE_SID=3D
ORA_NLS=3D/opt/app/oracle/product/9.2.0.8/ocommon/nls/admin/ data
ORACLE_TERM=3Dvt220
ORA_NLS32=3D/opt/app/oracle/product/9.2.0.8/ocommon/nls/admi n/data
ORA_NLS33=3D/opt/app/oracle/product/9.2.0.8/ocommon/nls/admi n/data
ORADATA=3D/opt/app/oracle/oradata1
ORACLE_HOME=3D/opt/app/oracle/product/9.2.0.8
The absolut path to the environment file is ok, and judging from the
"Environment AFTER" output it is also being read/sourced, nevertheless I
get the warning that there was an error when sourcing the file (and even
an incomplete one, it does not give me the $!). Anybody got an idea?
Thanks in advance,
Nora
------_=_NextPart_001_01CB2EE3.45DFDBC4--
Re: Env::Sourced - false error
On Jul 28, 10:59=A0pm, nora.hac... [at] stgkk.at ("HACKER Nora") wrote:
> Hi list,
>
> Maybe one of you has a clue why I get a false error message when using
> Env::Sourced. My (test-)script is as follows:
>
> #!/usr/bin/perl -w
> use strict;
> use warnings;
> require Env::Sourced; # "require" necessary in main programme, just not
> changed for testing
>
> my $w_conf =3D $ENV{'W_UMG_CONFIG_PFAD'};
> my $oraenv;
> my $orapat =3D '9208';
>
> print "Environment BEFORE:\n", `env |grep ORA`, "\n";
>
> if ( $orapat ne 'D' ) {
> =A0 =A0 =A0 =A0 $oraenv =3D "$w_conf/ora$orapat.env"; # coalesce path + f=
ilename
> =A0 =A0 =A0 =A0 print "OraEnv: $oraenv\n"; # check absolute file name
> =A0 =A0 =A0 =A0 Env::Sourced->import($oraenv) or warn "Fehler beim Setzen=
des
> Oracle-Environments: $!\n"; # set environment
>
> }
>
> print "\nEnvironment AFTER:\n", `env |grep ORA`, "\n";
>
> BUT I get the following output:
>
> oracle:/opt/data/magna/wartung/work/nora>./test.pl
> Environment BEFORE:
> ...
>
> OraEnv: /opt/data/magna/umgebungen/config/ora9208.env
> Fehler beim Setzen des Oracle-Environments:
The Env::Sourced import method only looks at the files passed
to the constructor and sets variables it finds in ENV.
IIUC, couldn't you just set oraenv directly at runtime:
$oraenv =3D "$w_conf/ora$orapat.env"; # coalesce path + filename
^^^^^^^^^
$ENV{ oraenv } =3D "$w_conf/ora$orapat.env";
> ...
>
> The absolut path to the environment file is ok, and judging from the
> "Environment AFTER" output it is also being read/sourced, nevertheless I
> get the warning that there was an error when sourcing the file (and even
> an incomplete one, it does not give me the $!). Anybody got an idea?
>
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
AW: Env::Sourced - false error
Hi,
Sorry for the late answer, I was kept busy at work and had no time to
dig in ...
> IIUC, couldn't you just set oraenv directly at runtime:
>
> $oraenv =3D "$w_conf/ora$orapat.env"; # coalesce path + filename
> ^^^^^^^^^
> $ENV{ oraenv } =3D "$w_conf/ora$orapat.env";
Charles, thanks for your answer - maybe I understood something wrong in
the documentation for Env::Sourced?
IIUC, with your above syntax I would set an environment variable with
the name "oraenv" and the value of "$w_conf/ora$orapat.env" - but not
read/set all the contents from my env-file.
The docu says, the reading in of a file is done by "use Env::Sourced (qw
/first/file/to/include.sh /second/file/to/include.sh);". Since I do not
know the database version (and with it the version of the env-file I
need) until sometime during the execution of my Perl programme, I can
only "require Env::Sourced;" at the beginning and set (import) the
environment later.
Kind regards,
Nora
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: Env::Sourced - false error
On Aug 17, 1:35=A0am, nora.hac... [at] stgkk.at ("HACKER Nora") wrote:
> Hi,
>
> Sorry for the late answer, I was kept busy at work and had no time to
> dig in ...
>
> > IIUC, couldn't you just set oraenv directly at runtime:
>
> > =A0 =A0 $oraenv =3D "$w_conf/ora$orapat.env"; # coalesce path + filenam=
e
> > =A0 =A0 =A0^^^^^^^^^
> > =A0 =A0 $ENV{ oraenv } =3D =A0"$w_conf/ora$orapat.env";
>
> Charles, thanks for your answer - maybe I understood something wrong in
> the documentation for Env::Sourced?
> IIUC, with your above syntax I would set an environment variable with
> the name "oraenv" and the value of "$w_conf/ora$orapat.env" - but not
> read/set all the contents from my env-file.
>
> The docu says, the reading in of a file is done by "use Env::Sourced (qw
> /first/file/to/include.sh /second/file/to/include.sh);". Since I do not
> know the database version (and with it the version of the env-file I
> need) until sometime during the execution of my Perl programme, I can
> only "require Env::Sourced;" at the beginning and set (import) the
> environment later.
>
Hm, If you can't set oraenv directly at runtime, delaying the
import will still work.
require Env::Sourced;
... # determine version, etc.
Env::Sourced->import( qw{first/file/to/include.sh /second/file/to/
include.sh} );
The Env::Sourced import() does all the sourcing. Here're the
relevant lines from the module source itself:
sub import
{
my $class =3D shift;
...
#--> Loop through all of the files passed to the module and:
#--> 1) Source the file, returning it's output as a hash
#--> 2) Include the sourced files environment into the
current
#--> environment. Any unchanged environment variables
should
#--> just be passed back to us as-is.
my [at] envs;
while(my $file =3D shift)
{
carp("$file does not exist") unless(-e $file);
....
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
AW: Env::Sourced - false error
Hi Charles,
> Hm, If you can't set oraenv directly at runtime, delaying the
> import will still work.
>
> require Env::Sourced;
>
> ... # determine version, etc.
>
> Env::Sourced->import( qw{first/file/to/include.sh /second/file/to/
> include.sh} );
Exactly. This is just what I posted in my original mail:
*** 1st mail START ***
> Maybe one of you has a clue why I get a false error message when using
> Env::Sourced. My (test-)script is as follows:
>
> #!/usr/bin/perl -w
> use strict;
> use warnings;
> require Env::Sourced; # "require" necessary in main programme, just
not
> changed for testing
>
> my $w_conf =3D $ENV{'W_UMG_CONFIG_PFAD'};
> my $oraenv;
> my $orapat =3D '9208';
>
> print "Environment BEFORE:\n", `env |grep ORA`, "\n";
>
> if ( $orapat ne 'D' ) {
> $oraenv =3D "$w_conf/ora$orapat.env"; # coalesce path + =
filename
> print "OraEnv: $oraenv\n"; # check absolute file name
> Env::Sourced->import($oraenv) or warn "Fehler beim Setzen des
> Oracle-Environments: $!\n"; # set environment
> }
>
> print "\nEnvironment AFTER:\n", `env |grep ORA`, "\n";
>
>
> BUT I get the following output:
>
> oracle:/opt/data/magna/wartung/work/nora>./test.pl
> Environment BEFORE:
> ORACLE_BASE=3D/opt/app/oracle
> ORACLE_SID=3D
> ORA_NLS=3D/opt/app/oracle/product/9.2/ocommon/nls/admin/data
> ORACLE_TERM=3Dvt220
> ORA_NLS32=3D/opt/app/oracle/product/9.2/ocommon/nls/admin/da ta
> ORA_NLS33=3D/opt/app/oracle/product/9.2/ocommon/nls/admin/da ta
> ORADATA=3D/opt/app/oracle/oradata1
> ORACLE_HOME=3D/opt/app/oracle/product/9.2
>
> OraEnv: /opt/data/magna/umgebungen/config/ora9208.env
> Fehler beim Setzen des Oracle-Environments:
>
> Environment AFTER:
> ORACLE_BASE=3D/opt/app/oracle
> ORACLE_SID=3D
> ORA_NLS=3D/opt/app/oracle/product/9.2.0.8/ocommon/nls/admin/ data
> ORACLE_TERM=3Dvt220
> ORA_NLS32=3D/opt/app/oracle/product/9.2.0.8/ocommon/nls/admi n/data
> ORA_NLS33=3D/opt/app/oracle/product/9.2.0.8/ocommon/nls/admi n/data
> ORADATA=3D/opt/app/oracle/oradata1
> ORACLE_HOME=3D/opt/app/oracle/product/9.2.0.8
>
> The absolut path to the environment file is ok, and judging from the
> "Environment AFTER" output it is also being read/sourced, nevertheless
> I get the warning that there was an error when sourcing the file (and
> even an incomplete one, it does not give me the $!). Anybody got an
> idea?
*** 1st mail END ***
--> My problem is not _how to do it_ but _why I get an error_ although
the import does obviously work, judging from the correctly set
variables.
Kind regards,
Nora
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/