DBD::ODBC Connects from command line, not thru crontab

Connectivity
Enthusiast

DBD::ODBC Connects from command line, not thru crontab

I'm hoping someone can help with this DBI error.  I have installed the perl DBD::ODBC driver into a custom directory and everything works fine when the scripts get kicked off via the command line.  At the top of each perl script I add the 'use lib pathto dbd::odbc'.  However when running in crontab the connect is having an issue.  It was first complaining about 

System information file not found. Please check the ODBCINI environment variable

So I fixed that by adding the envrionmental variable to the script.  I've also added 'LD_LIBRARY_PATH' and 'PERL5LIB' entries to each script as well, however I keep getting this error:

DBI Error => 1

DBI Errstr => 523 80 (SQL-82)

DBI State => S1000

Since it works fine from command line runs I'm assuming it has to have something to do with an environmental variable.  But in adding these I'm not sure what else it could be?  Please let me know if you wanted me to post anything for diags.  Thanks.
2 REPLIES
Teradata Employee

Re: DBD::ODBC Connects from command line, not thru crontab

Check the odbc.ini ($ODBCINI) file and see what is directory is assigned to "InstallDir" entry under [ODBC] section.  And verify, the DataDirect ODBC DM message files odbc.m & odbc.po are present in <InstallDir>/locale/en_US/LC_MESSAGES directory.

If there is an issue, correcting it will let you see actual error message.

Enthusiast

Re: DBD::ODBC Connects from command line, not thru crontab

I found out the issue is with the LD_LIBRARY_PATH.  I cannot set it within the perl script using:

$ENV{LD_LIBRARY_PATH} = '/opt/app/d1car1m6/.perl/usr/lib64';

So I created this entry in crontab and now it is working:

30 * * * * (export LD_LIBRARY_PATH=/opt/app/d1car1m6/.perl/usr/lib64; /opt/app/d1car1m6/bin/SendReports.pl > /dev/null 2>&1)