in reply to Re: Perl Environment Variable
in thread Perl CGI Environment Variable

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

Replies are listed 'Best First'.
Re: Perl Environment Variable
by Abigail-II (Bishop) on Jan 30, 2004 at 09:47 UTC
    Oh, sure it's working. The Perl program *is* getting the environment variable. However, the variable isn't set. Programs run from cron have hardly any environment variables set. And that makes sense. "HOME" is something associated with a user logged on. A program run from cron isn't started by a user - so there's no "HOME" environment variable.

    You either need to set it explicitely yourself, or you should write your program in such a way you don't need the variable.

    Abigail

      I get around this by writing my crontab as such:
      0 0 * * * ssh yourhost yourscript
      You could also use rsh if you were so inclined. The [r|s]sh in to your local machine creates a login shell, thereby setting the environment to what one might expect.

      thor

Re: Re: Re: Perl Environment Variable
by halley (Prior) on Jan 30, 2004 at 15:26 UTC
    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 ]