You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Anthony Gardner <cy...@yahoo.co.uk> on 2005/09/07 17:39:44 UTC

Losing ENV variables

Hola,

We're using apache/1.3.33 and mod_perl/1.29.

the problem is, a personal ENV variable is set in my
environment and read from a script like .....

my $ENVNAME   = $ENV{MY_PERSONAL_ENV} || 'STHELSE';

When the server is started a fresh, I can display my
ENV on my webpage but when I press refresh, it
disappears ...... never to be seen again.

The contents of the ENV var is used to find a file and
require it. So .....

require "General/Config_$ENVNAME" ;
 

What else do you need to know? Well, the script that
contains this code is not loaded at server start up
(not in startup.pl) for instance. Sometimes it works,
sometimes it doesn't (that old cliche). 

I could try work arounds but b4 I do, I'd like to
understand what may be going on here.

any pointers would be great.

CIA

-Ants





	
	
		
___________________________________________________________ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

Re: Losing ENV variables

Posted by Pratik <pr...@gmail.com>.
Have a look at http://perl.apache.org/docs/1.0/guide/config.html#PerlSetEnv_and_PerlPassEnv

Thanks,
Pratik

On 9/7/05, Anthony Gardner <cy...@yahoo.co.uk> wrote:
> Hola,
> 
> We're using apache/1.3.33 and mod_perl/1.29.
> 
> the problem is, a personal ENV variable is set in my
> environment and read from a script like .....
> 
> my $ENVNAME   = $ENV{MY_PERSONAL_ENV} || 'STHELSE';
> 
> When the server is started a fresh, I can display my
> ENV on my webpage but when I press refresh, it
> disappears ...... never to be seen again.
> 
> The contents of the ENV var is used to find a file and
> require it. So .....
> 
> require "General/Config_$ENVNAME" ;
> 
> 
> What else do you need to know? Well, the script that
> contains this code is not loaded at server start up
> (not in startup.pl) for instance. Sometimes it works,
> sometimes it doesn't (that old cliche).
> 
> I could try work arounds but b4 I do, I'd like to
> understand what may be going on here.
> 
> any pointers would be great.
> 
> CIA
> 
> -Ants
> 
> 
> 
> 
> 
> 
> 
> 
> ___________________________________________________________
> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
> 


-- 
http://www.rails.info - Coming Soon !

Re: Losing ENV variables

Posted by Boysenberry Payne <bo...@humaniteque.com>.
I think %ENV is particular to each apache child, so you might be 
"loosing" it because you're going to another
child process.

There are several modules that can help do this for you.  I'm sure 
someone here can help you with some names.
Otherwise you can look at using a database or flat file to store large 
pieces of info.

I remember reading somewhere that there is a module that will allow you 
to tie variables somehow to keep them persistent
across children...


Boysenberry

boysenberrys.com | habitatlife.com | selfgnosis.com

On Sep 7, 2005, at 10:39 AM, Anthony Gardner wrote:

> Hola,
>
> We're using apache/1.3.33 and mod_perl/1.29.
>
> the problem is, a personal ENV variable is set in my
> environment and read from a script like .....
>
> my $ENVNAME   = $ENV{MY_PERSONAL_ENV} || 'STHELSE';
>
> When the server is started a fresh, I can display my
> ENV on my webpage but when I press refresh, it
> disappears ...... never to be seen again.
>
> The contents of the ENV var is used to find a file and
> require it. So .....
>
> require "General/Config_$ENVNAME" ;
>
>
> What else do you need to know? Well, the script that
> contains this code is not loaded at server start up
> (not in startup.pl) for instance. Sometimes it works,
> sometimes it doesn't (that old cliche).
>
> I could try work arounds but b4 I do, I'd like to
> understand what may be going on here.
>
> any pointers would be great.
>
> CIA
>
> -Ants
>
>
>
>
>
> 	
> 	
> 		
> ___________________________________________________________
> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with 
> voicemail http://uk.messenger.yahoo.com
>
>


Re: Losing ENV variables

Posted by Arun Pandey <ar...@cybage.com>.
How about setting it up in your  apache startup file (or your apache conf
file) ?
something like
PerlSetEnv myenv value
so that all your child instances start up with the env variable  already
set

-Arun
----- Original Message ----- 
From: "Anthony Gardner" <cy...@yahoo.co.uk>
To: <mo...@perl.apache.org>
Sent: Wednesday, September 07, 2005 9:09 PM
Subject: Losing ENV variables


> Hola,
>
> We're using apache/1.3.33 and mod_perl/1.29.
>
> the problem is, a personal ENV variable is set in my
> environment and read from a script like .....
>
> my $ENVNAME   = $ENV{MY_PERSONAL_ENV} || 'STHELSE';
>
> When the server is started a fresh, I can display my
> ENV on my webpage but when I press refresh, it
> disappears ...... never to be seen again.
>
> The contents of the ENV var is used to find a file and
> require it. So .....
>
> require "General/Config_$ENVNAME" ;
>
>
> What else do you need to know? Well, the script that
> contains this code is not loaded at server start up
> (not in startup.pl) for instance. Sometimes it works,
> sometimes it doesn't (that old cliche).
>
> I could try work arounds but b4 I do, I'd like to
> understand what may be going on here.
>
> any pointers would be great.
>
> CIA
>
> -Ants
>
>
>
>
>
>
>
>
> ___________________________________________________________
> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with
voicemail http://uk.messenger.yahoo.com


Re: Losing ENV variables

Posted by Perrin Harkins <pe...@elem.com>.
On Thu, 2005-09-08 at 10:36 -0500, Boysenberry Payne wrote:
>  From Chapter 5 Maintaining State:
> 
> It uses IPC::Shareable and requires Storable
> It ties Perl data structures (scalars and hashes, but not arrays.)
> the idiom:
> tie %H, 'IPC::Shareable', 'Test', {create => 1, mode => 0666};
> on success it will tie %H to the shared memory segment.
> 
> You should be able to get the data from all of your child processes
> once it's tied.
> 
> The book suggests using tied(%hash)->shlock and tied(%hash)->shunlock
> to lock the variable before updating and unlocking afterwards to prevent
> multiple processes from updating at the same time.

I don't think this is relevant for the ENV variables problem, but I
wanted to point out that IPC::Shareable is a lot slower (and more
temperamental) than some other choices like Cache::FastMmap, BerkeleyDB,
or even MySQL.  I don't recommend using it at this point.

- Perrin


Re: Losing ENV variables

Posted by Boysenberry Payne <bo...@humaniteque.com>.
I got the following from "Writing Apache Modules with Perl and C" by 
Lincoln Stein & Doug MacEachern


 From Chapter 5 Maintaining State:

It uses IPC::Shareable and requires Storable
It ties Perl data structures (scalars and hashes, but not arrays.)
the idiom:
tie %H, 'IPC::Shareable', 'Test', {create => 1, mode => 0666};
on success it will tie %H to the shared memory segment.

You should be able to get the data from all of your child processes
once it's tied.

The book suggests using tied(%hash)->shlock and tied(%hash)->shunlock
to lock the variable before updating and unlocking afterwards to prevent
multiple processes from updating at the same time.


Hope that helps...

Boysenberry

boysenberrys.com | habitatlife.com | selfgnosis.com

On Sep 7, 2005, at 10:39 AM, Anthony Gardner wrote:

> Hola,
>
> We're using apache/1.3.33 and mod_perl/1.29.
>
> the problem is, a personal ENV variable is set in my
> environment and read from a script like .....
>
> my $ENVNAME   = $ENV{MY_PERSONAL_ENV} || 'STHELSE';
>
> When the server is started a fresh, I can display my
> ENV on my webpage but when I press refresh, it
> disappears ...... never to be seen again.
>
> The contents of the ENV var is used to find a file and
> require it. So .....
>
> require "General/Config_$ENVNAME" ;
>
>
> What else do you need to know? Well, the script that
> contains this code is not loaded at server start up
> (not in startup.pl) for instance. Sometimes it works,
> sometimes it doesn't (that old cliche).
>
> I could try work arounds but b4 I do, I'd like to
> understand what may be going on here.
>
> any pointers would be great.
>
> CIA
>
> -Ants
>
>
>
>
>
> 	
> 	
> 		
> ___________________________________________________________
> Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with 
> voicemail http://uk.messenger.yahoo.com
>
>