> I need to get a value from an environment variable VALUE. This value is
> set by an shell script which location is stored in anonther environment
> variable called SCRIPT. So I first call the shell script by
>
> `. \$SCRIPT`;
>
> and extract then the value of VALUE by
>
> my $value = $ENV(VALUE);
>
> But something does not work, so $value is empty. As the shell script
> produces also an echo output I catch it by using
>
> my @output = `. \$SCRIPT`;
>
> I get this output correctly, but VALUE is still empty! I also tried also
>
> system(\$SCRIPT`);
>
> and
>
> `. /place/of/my/shellscript.sh`;
>
> Both don't have the wished effect.
>
> When I call the shell script in the shell and the start my perl script
> VALUE is set and available for my perl script.
>
> What is wrong?
Unfortunately, your understanding of processes. A child process cannot
alter the environment of its parent.
Take a look at Shell::Source on CPAN.
--
Paul Johnson - pa...@pjcj.net
http://www.pjcj.net
Todays problem:
I need to get a value from an environment variable VALUE. This value is
set by an shell script which location is stored in anonther environment
variable called SCRIPT. So I first call the shell script by
`. \$SCRIPT`;
and extract then the value of VALUE by
my $value = $ENV(VALUE);
But something does not work, so $value is empty. As the shell script
produces also an echo output I catch it by using
my @output = `. \$SCRIPT`;
I get this output correctly, but VALUE is still empty! I also tried also
system(\$SCRIPT`);
and
`. /place/of/my/shellscript.sh`;
Both don't have the wished effect.
When I call the shell script in the shell and the start my perl script
VALUE is set and available for my perl script.
What is wrong?
Konrad
Ah, okay! Thanks a lot!
Konrad