Re: appended crontab entries with py script

2005-09-14 Thread rbt
On Tue, 2005-09-13 at 23:18 -0400, Mike Meyer wrote:
> rbt <[EMAIL PROTECTED]> writes:
> 
> > How can I safely append a crontab entry to a crontab file
> > progammatically with Python?
> 
> Well, one way would be to invoke the system crontab utility and use an
> "editor" that passes the file to your program, and reads the results
> back.
> 
> > I need to handle crontabs that currently have entries and crontabs that
> > are empty. Also, I'd like this to work across Linux and BSD systems.
> >
> > Any pointers?
> 
> I think most Free Unix systems use the Vixie cron, and the non-free
> ones have a "crontab" command (do some of them call it cron?) with the
> same API. So you're pretty safe using that.
> 
> If you want to assume that you're going to have the vixie cron, you
> could dig into it's guts to see what it does for locking, and do that
> by hand.
> 
> current_crontab.txt')
cur_cron.read()
cur_cron.close()
fp = file('current_crontab.txt', 'a')
print >> fp, "0 * * * * %s/.theft_recovery.py" %home
fp.close()
load = os.popen('crontab current_crontab.txt')
load.read()
load.close()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: appended crontab entries with py script

2005-09-13 Thread Mike Meyer
rbt <[EMAIL PROTECTED]> writes:

> How can I safely append a crontab entry to a crontab file
> progammatically with Python?

Well, one way would be to invoke the system crontab utility and use an
"editor" that passes the file to your program, and reads the results
back.

> I need to handle crontabs that currently have entries and crontabs that
> are empty. Also, I'd like this to work across Linux and BSD systems.
>
> Any pointers?

I think most Free Unix systems use the Vixie cron, and the non-free
ones have a "crontab" command (do some of them call it cron?) with the
same API. So you're pretty safe using that.

If you want to assume that you're going to have the vixie cron, you
could dig into it's guts to see what it does for locking, and do that
by hand.

 http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


appended crontab entries with py script

2005-09-13 Thread rbt
How can I safely append a crontab entry to a crontab file
progammatically with Python?

I need to handle crontabs that currently have entries and crontabs that
are empty. Also, I'd like this to work across Linux and BSD systems.

Any pointers?
-- 
http://mail.python.org/mailman/listinfo/python-list