Welcome to WebmasterWorld Guest from 54.196.208.6

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

perl scripts automatically run on the apache server

perl scripts automatically run on the apache server in linux

     
9:52 am on Aug 30, 2002 (gmt 0)

New User

10+ Year Member

joined:Aug 30, 2002
posts:4
votes: 0


I need the program in perl that it automatically takes the input from the log file and updates in mysql database. That is the log file data changes every seconds. while the data changes in the logfile, the script should take the data and put it into the database. That is the script is always running and watching in the server for the log file updates. How to do this in perl. Please help me to solve this.

Thanks.
S.Ramesh.

10:25 am on Aug 30, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 22, 2002
posts:1782
votes: 0


This is from recipe 8.5 in the Perl Cookbook:

Read until end of file. Sleep, clear the EOF flag, and read some more. Repeat until interrupted.

for (;;) { 
while (<FH>) { add to database }
sleep $SOMETIME;
seek (FH, 0, 1);
}
12:21 pm on Aug 30, 2002 (gmt 0)

New User

10+ Year Member

joined:Aug 30, 2002
posts:4
votes: 0


hello friend,

Thanks for your reply. But this code runs if we run the script in the konsole. But I need the script which automatically runs while the server starts run.

Thanks.
S.Ramesh.

12:36 pm on Aug 30, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 22, 2002
posts:1782
votes: 0


I might be wrong but how about adding the perl script to the init script that starts and stops your webserver?
12:44 pm on Aug 30, 2002 (gmt 0)

New User

10+ Year Member

joined:Aug 30, 2002
posts:4
votes: 0


You are not wrong. The script is working correctly.

We run this script by ourself in konsole. But my need is, " this program should be controlled by the server. If the server starts running, this program also need to run." That is, this program is controlled by the server.

Thanks!
S.Ramesh.

1:15 pm on Aug 30, 2002 (gmt 0)

Full Member

10+ Year Member

joined:Mar 14, 2002
posts:325
votes: 0


That script varies depending on your distro. At Debian, for example, you'd add a line at the start) case of /etc/init.d/apache.