bat_man2282 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am running a perl script which uses the DBI module. I have no problems running the script as haredi (which is my unix user), but when I run it from cron (which is run as the same user by the way) I get the following error message: invalid or unknown NLS parameter value specified (DBD ERROR: OCISessionBegin). Any thoughts?

Replies are listed 'Best First'.
Re: PERL DBI Error when run from CRON
by rdfield (Priest) on Nov 14, 2003 at 23:36 UTC
    When running scripts as CRON the environment variables aren't set. Best to create a small script which exports the correct values for ORACLE_HOME, ORACLE_SID, NLS_LANG and update the PATH to include ORACLE_HOME/bin and run that as part of your script. Another way is to set ORAENV_ASK=NO and run the oraenv script with your SID.

    rdfield

Re: PERL DBI Error when run from CRON
by dws (Chancellor) on Nov 14, 2003 at 23:37 UTC
    ... but when I run it from cron ...

    cron jobs start with a truncated environment. (To see this, try a cron job that does a printenv.) If OCI is depending on environment variables being set (e.g., for an NLS parameter), you're probably going to need to set that variable in a wrapper script that you invoke from cron.

Re: PERL DBI Error when run from CRON
by etcshadow (Priest) on Nov 15, 2003 at 17:11 UTC
    Also, a simple way to get all of your typical environment in is to make your cron entry just source your profile script. If you do anything wacky or shell-specific in your profile script, then this might not work (since your crontab gets run through "sh" the system shell). Something like:
    * * * * * source ~me/.bash_profile ; perl my_script.pl etc

    ------------
    :Wq
    Not an editor command: Wq