Hi all,
i have a curious problem with environment in threads.
Following code:
while (1) {
#reading enviroment from a textfile (empty at first loop walkthrough)
open (ENVIRONMENT, "<envtat.txt")
@enviVars = <ENVIRONMENT>;
close ENVIRONMENT;
foreach $envi (@enviVars){
$envi =~ /(^.+=)(.+$)/;
my $envname=$1;
my $envval=$2;
$envname =~ s/=//gi;
$ENV{$envname}=$envval;
}
# executing an command (which needs system environment)
my $output = `$cmd`;
#writing environment to textfile
open(LOGF, ">envtat.txt")
flock(LOGF, 2);
foreach $ev (keys %ENV) {
next if $ev eq "_" || $ev eq "PWD";
print LOGF "$ev=";
$val = $ENV{$ev};
$val =~ s/'/'"'"'/g;
print LOGF "$val\n";
}
flock(LOGF, 8);
close(LOGF);
} # end of while loop
This program executes an command (once) which sets special environment
variables. All following commands (also executed by this perl script) need
these environment varibles. So, in $cmd is in every loop walkthrouh another
command.
The code above works. After I've executed the first command which sets the env
variables, all following commands can work with the set environment.
But the problem is: This does not work in a thread :(
Can anyone help me this this issue ? Are there any workarounds ?
I am currently very confused.
Many many many thanks in advance for help.
ps: Yes, for my use I need to do this in threads
pps: When I say threads, I mean IThreads (Perl 5.8.x)
- Clemens Kalbfuss
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.