[prog] Perl from cron

jennyw jennyw at dangerousideas.com
Thu Jun 23 10:01:07 EST 2005


Hi, there! I guess my first message wasn't clear -- all those things have 
been tried. The value of the variable should be the abs path of the 
directory that the script resides in. When run from cron, it's undefined.

I tried setting the path env var in the script called by cron, too, but it 
didn't have an effect. I looked through the rest of the env vars, especially 
looking for anything path or Perl related, but I didn't see anything that 
seems like it should make a difference.

Thanks!

Jen

----- Original Message ----- 
From: "Kathryn Andersen" <kat_lists at katspace.homelinux.org>
To: <programming at linuxchix.org>
Sent: Wednesday, June 22, 2005 2:13 PM
Subject: Re: [prog] Perl from cron


> On Wed, Jun 22, 2005 at 12:28:14PM -0700, jennyw wrote:
>> Short story: I'm having trouble with a Perl script running from cron -- 
>> it works great from a regular login shell, but in cron there are issues.
>
> Well, I don't know what the specific problem might be with FindBin, but
> one thing that happens frequently when one has a program or script which
> works fine in a regular login shell, but doesn't work in cron is that
> the environment is different.  In your login shell, various environment
> variables have been set (first in a global /etc/bashrc file (for
> example) and then from .*rc files in your home directory).  But cron
> does not do this; its environment is the bare minimum.  That's why, when
> you see examples of a crontab, you see the commands being given as
> full-path commands -- because the PATH environment variable isn't
> guaranteed to be there.
>
> I suggest you write yourself a little script which does two things:
> a) it contains the offending bits of code which are behaving
> differently; like, print out the value of $RealBin after it's supposed
> to be initialized.
>
> b) prints out the environment.
>
> That might help you track down what the problem is.
>
> If it *is* in the environment, you could then change the line in your
> crontab to set the offending variable explicitly, in the same line that
> the required command is called.
>
> OFFENDING_VAR=value /path/to/command
>
> Actually... I also have a suspicion which variable it is: the PATH
> variable mentioned above.  Because doesn't FindBin use PATH in order to
> do its thing?
>
> Kathryn Andersen
> -=-=-=-=-=-=-=-=-
> "He who trusts in his own mind is a fool;
> but he who walks in wisdom will be delivered." Proverbs 28:26
> -- 
> _--_|\     | Kathryn Andersen <http://www.katspace.com>
> /      \    |
> \_.--.*/    | GenFicCrit mailing list 
> <http://www.katspace.com/gen_fic_crit/>
>      v     |
> ------------| Melbourne -> Victoria -> Australia -> Southern Hemisphere
> Maranatha!  | -> Earth -> Sol -> Milky Way Galaxy -> Universe
> _______________________________________________
> Programming mailing list
> Programming at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/programming
> 



More information about the Programming mailing list