View Single Post
  #2 (permalink)  
Old 01-17-05, 02:04 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
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.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote