Current location: Hot Scripts Forums » Programming Languages » Perl » Cron and Perl problem


Cron and Perl problem

Reply
  #1 (permalink)  
Old 01-16-05, 08:43 AM
erikbjork erikbjork is offline
New Member
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Cron and Perl problem

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!

Last edited by erikbjork; 01-16-05 at 09:41 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-17-05, 03: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]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-19-05, 11:58 PM
Chas Chas is offline
Coding Addict
 
Join Date: Oct 2003
Location: California
Posts: 359
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
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.
That's what I've generally run into as well. I would start by checking permissions then try paths (although it looks like you've done that.)

~Charlie
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie found a solution to a date problem. mickey_kamer Perl 4 05-09-07 06:54 AM
Perl coder needed XGamingZone Perl 1 09-17-04 08:19 AM


All times are GMT -5. The time now is 10:02 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.