Perl - Error loading module.

Hi,
I have a strange issue in my script.

When script is run from command prompt it runs fine,but when run from cron it exist with error message.

I narrowed down the issue and found that " use Mail::Sender;" is the culprit.
If I comment the statment the code runs fine in both command and cron.
Error thrown is :

SVCENV: MIME::Base64 object version 3.01 does not match bootstrap parameter 2.12 at /usr/perl5/5.8.4/lib/sun4-solaris-64int/DynaLoader.pm line 253

Can anyone assist in solving it.

Thanks in advance
Dheeraj

The big difference between running from the command line and using cron is that the command line version has inherited all of your personal profile environment settings, but the cron version has virtually no profile at all.

In cron, you can try this...
<date time> . <path to home>/.profile; <perl script>
to source your own profile before attempting to run the Perl.

I tried that, actually my perl script is called from a shell script(launch.sh).so I have made an entry to call .profile in the launch.sh .
but that doesnt sovle my problem.

At a glance, I bet cron is using a different perl than you are.

@Kodak :
Quote : At a glance, I bet cron is using a different perl than you are.
How do we find which Perl is cron using ??

Create a shell script:

#!/bin/sh
which perl

Then run it from the command line, then run it from cron. Compare the results. If the result is different, then make sure you're explicitly using the perl you get from your command line.

If run from cron , it wont find any perl , that is why I have a launch script ( launch.sh )which explicitly calls the needed perl .
More over I have also made an explicitly call to .profile in my launch script.

Consider reinstall MIME::Base64. This module is actually written in C, and it seems like the error is suggesting that there is a version mismatch between the Perl side of the module, and the object side of the module (i.e. the C XS implementation).

If you google, you should find something similar, like this:
More on "IO object version does not match bootstrap parameter" error

Take a look at Dave's response.

A couple of things to consider.

First, the ~/.profile is not the only file sourced during an interactive login. Depending on the shell there are also files located in /etc/ that are sourced. So, you may still not have the entire environment.

Second, you really don't need the entire profile, but finding exactly what you do need may be a problem. Remember cron is not using a 'login' environment, so somethings may even be skipped when spawning a shell. I would start with setting a secure PATH or even hard-coding the full paths in your shell wrapper. You can add a call to 'env' at the top of your wrapper and redirect the output to a file. Then when you run it manually and via cron, you can see the differences in the environment. You obviously found that the perl binary was not in your path.

Since the module you mention is C based, there is a good chance that a necessary library or binary dependency is not available in your environment when running via cron. You may need to add LD_LIBRARY_PATH or LD_RUN_PATH. You can execute perl with the '-V' option to see how the binary was compiled. This may give you a clue on what libraries and paths are needed. Another thing to look at is using 'ldd' against any binaries to see their library dependencies.

I hope this helps.

  • B

@bwhitehd
I mentioned LD_LIBRARY_PATH in my .profile ,which executed in my launch.sh script. So
when running thru cron ,I am not supposed to miss anything.!
@cbkihong
Reinstall MIME::Base64 ,looks like a promising option.

~Thanks
Coolbhai