LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-23-2004, 05:03 AM   #1
webwiznz
LQ Newbie
 
Registered: May 2004
Location: Auckland, NZ
Distribution: Debian Etch
Posts: 19

Rep: Reputation: 0
Cron Mystery / Perl


Im working on a ip accounting exercise to log traffic on a NAT router. (following the NAG2 guide). See thread :

http://www.linuxquestions.org/questi...hreadid=182610

In order to clear the iptables counters I have set a cron job (as root) using crontab <file>

5 3 * * * perl /root/ipcounters.pl

this perl script looks like :

-rwx------ 1 root root 1373 May 23 20:55 ipcounters.pl*

#!/usr/bin/perl
$_ = `iptables -L -v`;
do_some_text_extractions($_);

The script runs on schedule, but the syscall to iptables fails (silently). It appears as though its not running as root, which the iptables command requires. Ive tried all sorts of things, read the man pages (poor) some good tuts at:

http://support.gradwell.net/article.php?85
http://en.tldp.org/LDP/lame/LAME/lin...sing-cron.html

The script works fine manually as root, but not under cron. Hmmm.

BTW a related problem ive noticed is that the shebang syntax for perl scripts dont work for some reason.

whereis perl
perl: /usr/bin/perl

-rwx------ 1 root root 1373 May 23 20:55 ipcounters.pl*

[root@fileserver root] ./ipcounters.pl
bash: ./ipcounters.pl: bad interpreter: No such file or directory

perl ipcounters.pl
works ok

Any ideas on those two probs?
 
Old 05-23-2004, 10:47 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 67
Try using the full path to iptables:
$_ = `/sbin/iptables -L -v`;

Assuming that iptables is in /sbin
 
Old 05-23-2004, 06:11 PM   #3
webwiznz
LQ Newbie
 
Registered: May 2004
Location: Auckland, NZ
Distribution: Debian Etch
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks, that cracked it. Silly late night mistake.
P
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron Email Notification - Perl Script jamesyreid Programming 3 07-21-2009 07:56 AM
Cron and Perl question eagle683 Programming 3 07-30-2005 08:28 PM
Cron problems with perl slice Linux - Newbie 1 02-21-2005 10:49 AM
Trouble with perl script in Cron job thack111 Linux - General 7 11-25-2004 02:44 AM
how to make a cron entry? (perl) akaash Programming 2 05-06-2004 02:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration