This is what is happening:
- Perl forks itself. The main program then wait()'s
for the child to finish.
- The child gets a copy of everything that is in the
parents environment (actually, it shares the memory using
copy-on-write, but thats more detail than we need right now).
- When the child goes away, everything that was in the
child's copy is destroyed.
- When the parent resumes operation, it has the same
environment as before it forked since nothing ever actually
changed it's copy.
If you need to have a second process alter the memory
or environment of another process, you need to look into
programming with threads or shared memory. Your other
alternative would be inter-process communication.
| [reply] |
| [reply] |
The backticks execute the command in a subshell; so you're not changing the environment of the script that calls that subshell (i.e. your perl script). So you're not really doing anything wrong, per se. That's a limitation of the shell, not Perl. If you want to modify the environment your perl script is running under, do it by modifiying the %ENV hash from within your script.
I mistrust all systematizers and avoid them. The will to a system shows a lack of integrity -- F. Nietzsche
| [reply] [d/l] |
it is only modifying the environment of the subshell that is running your shell script. the syntax ". shellscript.sh" only works in sh/bash/etc. all it is doing is saying "run these commands as if i typed them at the command prompt". if you want to modify environment variables inside your perl script, you will need to modify $ENV yourself. | [reply] |
When referencing any code in your questions you should utilize <CODE> tags.
Now that thats out of the way, just dump using the sh script and update your variables via the %ENV hash as in $ENV{'JAVA_HOME'} etc.. However if sourcing existing sh files is mandantory, read the source file via your Perl script and regex for the name=value pairs and update the %ENV based on your results.
coreolyn
| [reply] [d/l] [select] |
Thanks...i found the porblem in my perl script....i was using
$ENV{$key} = chomp($value};
Whicc is wrong. i should have used
chomp($value);
$ENV{$key} = $value;
thanks to tye....he/she saved the day.....
Amit (amit_ra)
| [reply] [d/l] [select] |