Re: Perl Environment Variable
by davido (Cardinal) on Jan 30, 2004 at 05:14 UTC
|
It sounds like the environment under which your process is running doesn't have $ENV{"HOME"} defined (in other words the "HOME" environment variable isn't set). But it's hard to say because you didn't actually bother to explain what "it's not working!" means, so I can only guess. Did you get some error message that might mean something to one of us? Are you running under the "use warnings;" pragma so that if $ENV{"HOME"} is undefined you'll get a warning? That would be helpful.
Update:
When I say "It sounds like the environment under which your process is running doesn't have $ENV{"HOME"} defined...", I'm saying that it's probable that your spawned process is running under a different environment instance (ie, as a different user). Thus, even though you think HOME is set, it's not set in the environment under which your job is running. Turning warnings on might tell you that the hash element you're looking for isn't defined. Now you know one possible reason why.
| [reply] |
|
|
Hi,
Thanks for ur comments
The script runs perfectly when i run it from command line.
It's able to get those environment variables.
I have an another perl script whic is a cron process which would initiate my first script to do some action.
In this case its not able to get those environment variables.
sasi
| [reply] |
|
|
| [reply] |
|
|
|
|
Cron tasks are not shell sessions. You don't have the same environment. Your process has only the barest minimum environment setup, and that doesn't include $ENV{HOME} or other trivial niceties made by your .cshrc / .bashrc or other profile stuff.
-- [ e d @ h a l l e y . c c ]
| [reply] |
Re: Perl Environment Variable
by etcshadow (Priest) on Jan 30, 2004 at 06:37 UTC
|
(Building on your replies to the above questions:) you have to set up your environment for cron jobs... it doesn't just come for free.
Two easy ways to do this:
P.S. (update) This doesn't actually have anything to do with perl... it has to do with how environment variables are set and inherited, and how crond fits in with all that... if you want to see a really clear example of that, just put this in your crontab:
* * * * * env > ~/cron_env
And then see what's there (not much... certainly not as much you usually have in your shell, thanks to your rc/profile/.login file(s)).
------------
:Wq
Not an editor command: Wq
| [reply] [d/l] [select] |
Re: Perl Environment Variable
by coec (Chaplain) on Jan 30, 2004 at 07:53 UTC
|
I hope you haven't called your Perl script script. This is really bad practice under Unix as there is aleady a utility called script.
Try to avoid names like script and test as it will save you much heart-ache later. | [reply] [d/l] [select] |
Re: Perl Environment Variable
by Roger (Parson) on Jan 30, 2004 at 05:24 UTC
|
Are you running the other script under the same shell? May be your other script has modified the HOME environment variable. It would certainly help if you show us your code, as davido said.
| [reply] |
|
|
Hi,
I am getting a list of files in a text area
when i get this text area using the param function i got it as a scalar variable.
now i need it to be seperated in to an array based on the newline in the text area can anyone tell me how to do it.
i tried it with split i was not able to acive it
Thank you
sasi kumar
| [reply] |
|
|
| [reply] |