Re: Running DBI, ODBC in the crontab
am 12.04.2006 05:44:43 von jseger------=_Part_11281_10263796.1144813483859
Content-Type: text/plain; charset=WINDOWS-1252
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Run the following lines in both the command line and crontab:
perl -MData::Dumper -e' print Dumper @INC' >~/inc.log
env|sort >~/env.log
The first will have output that looks something like this:
perl -MData::Dumper -e' print Dumper @INC'
$VAR1 =3D '/usr/lib/perl5/5.8.7/i586-linux-thread-multi';
$VAR2 =3D '/usr/lib/perl5/5.8.7';
$VAR3 =3D '/usr/lib/perl5/site_perl/5.8.7/i586-linux-thread-multi';
$VAR4 =3D '/usr/lib/perl5/site_perl/5.8.7';
$VAR5 =3D '/usr/lib/perl5/site_perl';
$VAR6 =3D '/usr/lib/perl5/vendor_perl/5.8.7/i586-linux-thread-multi';
$VAR7 =3D '/usr/lib/perl5/vendor_perl/5.8.7';
$VAR8 =3D '/usr/lib/perl5/vendor_perl';
$VAR9 =3D '.';
Ignoring the "$VARn =3D" stuff, compare what is in the outputs on the comma=
nd
line and on the crontab output. Any of the paths that are missing in cron
should be added in cron. There are a number of ways to do that, but what I
suggest is creating a .setenv.sh (or some name that makes sense to you) and
add the variables to your environment (PERL5LIB) by sourcing that file as
part of your cron command line.
Another way is to add the lines to the top of your crontab:
PERL5LIB=3D
LD_LIBRARY_PATH=3D
If you use the setenv.sh method:
0 0 * * * /home/jeff/bin/jeffsscript.pl
becomes:
0 0 * * * cd /home/jeff/bin/ ; . .setenv.sh ; /home/jeff/bin/jeffsscript.pl
If you add it to your crontab, then your crontab looks something like this:
PERL5LIB=3D
LD_LIBRARY_PATH=3D
0 0 * * * /home/jeff/bin/jeffsscript.pl
It's important to remember though that these variables get set for
everything that runs in this crontab if you do it this way, although they
can be overridden using the first method.
The differences between the cron execution of env and the command line will
be huge.
On my linux box env from the command line spits out 83 lines. From cron it
is 10, and that includes some that I have added in. Most notably absent are
things like PERL5LIB and all of my ORACLE* variables. Anything that might
help can be added in using one of the methods above.
On 4/11/06, Stephen.Chung@ubs.com
>
> Hi,
>
> I am running a perl script, using DBI and ODBC (from DataDirect), on a
> linux box to connect to SQL server. It works fine if I run it from a sh=
ell
> command line.
>
> However, if I put it into a crontab (the same user), I got the following
> error:
>
> install_driver(ODBC) failed: Can't load
> '/QRT/ODBC/perlModule/myInstall/lib/auto/DBD/ODBC/ODBC.so' for module
> DBD::ODBC: libstdc++.so.5: cannot open shared object file: No such file o=
r
> directory at /sbcimp/run/pd/perl/5.8.3/lib/DynaLoader.pm line 229.
>
> at (eval 1) line 3
> Compilation failed in require at (eval 1) line 3.
> Perhaps a required shared library or dll isn't installed where expected
>
> The failure is at the line
>
> $dbh =3D DBI->connect
>
> Here is what I tried to diagnosis.
>
> 0. if I do "ldd /QRT/ODBC/perlModule/myInstall/lib/auto/DBD/ODBC/ODBC.so"
> from a shell command, there is a clear path associated with libstdc++.so.=
5
>
> 1. I checked (by printing out the environment variable's LD_LIBRARY_PATH
> within my perl script) the LD_LIBRARY_PATH, the path for item 0 is there.
>
> 2. if I repeat the item 0 within the perl script (when running in the
> crontab), the output indicates the library (ODBC.so) is fine with correct
> linkage.
>
> Every debugging output looks normal, and I just could not find the
> problem=85
>
> It will be greatly appreciated if some expert can share his experience
> with me.
>
> Many thanks.
>
> Best,
>
> Stephen Chung
>
>
>
> This communication is issued by UBS AG or an affiliate ("UBS") by the
> Sales or Trading Department to institutional investors only and is
> not research. It is for informational purposes and is not an official
> confirmation of terms. It is not guaranteed as to accuracy, nor is it
> a complete statement of the financial products or markets referred
> to. Opinions expressed are subject to change without notice and may
> differ or be contrary to the opinions or recommendations of UBS
> Investment Research or the opinions expressed by other business areas
> or groups of UBS as a result of using different assumptions and
> criteria. UBS may, as principal or agent, have position in,
> underwrite, buy or sell, make a market in, or enter into derivatives
> transactions in relation to any financial instrument or asset
> referred to in this email. Unless stated specifically otherwise, this
> is not a recommendation, offer or solicitation to buy or sell and any
> prices or quotations contained herein are indicative only. UBS has
> policies and procedures designed to minimise the risk that that
> officers and employees are influenced by any conflicting interest or
> duty and that confidential information is improperly disclosed or
> made available. To the extent permitted by law, UBS does not accept
> any liability arising from the use of this communication.
> For additional information, please contact your local sales or
> trading contact. (c) 2005 UBS. All rights reserved.
> Intended for recipient only and not for further distribution
> without the consent of UBS.
>
>
--
------------------------------------------------------------ ---------------=
-----------------------------------
The darkest places in hell are reserved for those who maintain their
neutrality in times of moral crisis.
Dante Alighieri (1265 - 1321)
They who would give up an essential liberty for temporary security, deserve
neither liberty or security.
Benjamin Franklin
------------------------------------------------------------ ---------------=
-----------------------------------
------=_Part_11281_10263796.1144813483859--