Quote:
|
Originally Posted by erikbjork
Hi!
I have a code that works perfectly well when I'm running it from the command line in Linux. But when I'm running it as a cron job it doesn't seem to work. (I'm running it from /etc/crontab) I think I've figured out that it is the split function that stops working. It looks like this:
@data = split(/(.*):[ ]*(.*)°(.*)=[ ]*(.*)°(.*)=[ ]*(.*)°(.*)/);
When I'm trying to print for example $data[1] perl tells me:
Use of uninitialized value in print at /searchpath/script.pl line 80, <INPUT> line 1.
The input comes from the following line:
open( INPUT, "/usr/bin/sensors | /bin/grep \"sensor = thermistor\" |");
I can print the input lines one by one, but not split them. I print them by putting the following line just before the split command:
print($_);
Anyone who has any ideas? I have been googling around for this for a few hours now and I'm getting kind of tired.
Thank you!
|
This is just a guess, but a heck of a lot of the problems I've had like this with perl (runs at the prompt, not via cron) have been due to two things: permissions and paths. Sometimes cron needs the full path specified, and 'who' the script is running as under cron has tripped me up a bunch of times too.
But I don't know, I don't see anything there that looks wrong, so maybe someone else here can spot something.