For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > March 2005 > cgi form generates a cronjob









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cgi form generates a cronjob
Frank Delatorre

2005-03-25, 3:55 pm

Hello,

I hope this is the right forum to ask this question:

Is it possible to generate a crontab file from a perl driven CGI script?

If so, what are the key steps?

I've been thinking about how to develop this but for some reason I cannot rectify, in my head, how to edit a crontab file as www when www is not really a user in the /home dir...

thanks
Frank
Nestor Florez

2005-03-25, 3:55 pm

Frank,

You could do a "sudo www" command and using "sed" you culd edit

Now I have never done anything like this but I can see how I would approach
it to edit the cronjob.

God Luck!!!

-----Original Message-----
From: FRANK DELATORRE <fdelatorre@comcast.net>
Sent: Mar 25, 2005 9:48 AM
To: beginners-cgi@perl.org
Subject: cgi form generates a cronjob

Hello,

I hope this is the right forum to ask this question:

Is it possible to generate a crontab file from a perl driven CGI script?

If so, what are the key steps?

I've been thinking about how to develop this but for some reason I cannot rectify, in my head, how to edit a crontab file as www when www is not really a user in the /home dir...

thanks
Frank


Bob Showalter

2005-03-25, 8:55 pm

FRANK DELATORRE wrote:
> Hello,
>
> I hope this is the right forum to ask this question:
>
> Is it possible to generate a crontab file from a perl driven CGI
> script?
>
> If so, what are the key steps?
>
> I've been thinking about how to develop this but for some reason I
> cannot rectify, in my head, how to edit a crontab file as www when www
> is not really a user in the /home dir...


Typically you would use the crontab(1) program to submit a new crontab. If
you need to get the current crontab first, use crontab -l. Obviously you
can't use crontab -e from a script.

So,

# read current crontab
my @lines = `crontab -l`;

... change @lines as necessary ...

# submit updated crontab
open F, "|crontab" or die $!;
print F @lines;
close F;

HTH

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com