473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Cron does not find method in required library

2
Hi, long time listener, first time caller so to speak. Thanks to everyone who has answered other questions that I've found and used.

I'm self-taught in Perl and have been hacking at it for more than five years now, so your patience with me is appreciated.

Here's my issue. I have a Perl script (say, myscript.cgi) that is set to run on a cron job. It has a require line to another function library. (This is a procedural program, not OO):

require "mylib.pl";

The library is in the same directory as the script. When i call the script using a browser, it renders fine in the browser. i.e.,
http://myserver.com/cgi-bin/myscript.cgi

When I set the same myscript.cgi to run as a cron job, I get an error that one of the functions in mylib.pl can't be found:
Undefined subroutine &main::my_subroutine called at /home/my_username/public_html/mysite/cgi-bin/myscript.cgi line 77, <FHANDLE> line 6.

Here's the rub: there are several calls in myscript to functions located in mylib. It is only functions that are added to the library recently that cause this failure. In other words, if the code hasn't changed in a while, it runs fine, regardless of where the procedure is located. But if I create a new procedure in mylib.pl, the cron version won't run it.

I am no expert on perl compilation, but if I am guessing that the problem is the cron job sees some cached version of my script somewhere and runs that one, failing to recompile and see my new function.

Does anyone know if my hunch is right? If so, how do I force it to recompile? Or am I totally off track?

Thanks in advance, it is very much appreciated.
Mar 6 '08 #1
3 1541
eWish
971 Expert 512MB
I would try adding the absolute path to the file and add the die function.

Expand|Select|Wrap|Line Numbers
  1. require '/path/to/file.pl' || die "Can't open /path/to/file.pl: $!\n"; 
--Kevin
Mar 6 '08 #2
KevinADC
4,059 Expert 2GB
You wouldn'ty be the first person that thought they were editing and saving a file in the correct directory but come to find they weren't. So make sure the file is the correct one that your main perl script is using.
Mar 6 '08 #3
Zudnic
2
Thank you both for your replies, and I apologize for the delay in getting back to you.

I inserted a hard path to the Perl library, and verified using a hard "print" that it's the right one. The program ran under the cron and did not fail on the die clause.

However, I found an old portion of the code that included a relative path. Once corrected, the code now runs fine.

Thank for the advice that pointed me in the right direction. It's appreciated.
Mar 7 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Phil Powell | last post by:
if ($this->isSuccessful && !$hasMogrified) { // SMACK IT ALL TOGETHER @imagecopyresampled($newImage, $image, $config, $config, 0, 0, $config, $config, $origWidth, $origHeight); // SAVE TO FILE...
3
by: Al | last post by:
I've been attempting to run a small java applet via a cron on linux with the following command: 50 * * * * /home/usr/java/program/;java runScript I know runScript is running but the gui never...
6
by: Mark | last post by:
I have been working for quite some time on this issue which in theory should be quite simple. The problem is that the Cancel and Save events are not fired when their respective buttons are...
3
by: the.natalie | last post by:
Hi. I am a newbie to mysql, cron, and shell scripting, so please bear with me. I have a script that is used for updating an image directory based on contents in a database. The script does the...
4
by: pushpen | last post by:
I'm trying to run the following php code along with gd library as a cron job ,but cron is not generating any output. When I run this code from my browser I get an image correctly. Somebody please...
4
by: Phil | last post by:
I have a php script that queries some Oracle DB and outputs a single line of plain text with <brat the end for each query. This is Apache2, php4.4.8 and Oracle Instant Client 10.1.0.5 all on CentOS...
4
by: Aidan | last post by:
Hi, I'm having a bit of trouble with a python script I wrote, though I'm not sure if it's related directly to python, or one of the other software packages... The situation is that I'm trying...
4
by: Stephen Cattaneo | last post by:
Hello all, I am attempting to execute an automated test (written in Python) via cron. I have to check the HOSTNAME variable as part of the test, oddly under cron the HOSTNAME environment...
0
by: Cameron Simpson | last post by:
On 17Aug2008 21:25, John Nagle <nagle@animats.comwrote: Because $HOSTNAME is a bash specific variable, set by bash but NOT EXPORTED! Like $0 and a bunch of other "private" variables, subprocesses...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.