[Tutor] exec* and co.

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Sat, 24 Feb 2001 02:10:39 -0800 (PST)


On Sat, 24 Feb 2001, Viktor Lakics wrote:

> I recently wrote a little python script to run fetchmail at certain
> times (depending on whether it is a weekday or weekend and certain
> times on a day). I have the script working, except the very last
> bit, to invoke fetchmail. Here is what I want with pseudo-code:
> 
> if weekDay() and workHours():
> 	run "fetchmail -d 2000"
> else:
> 	sys.exit
> 
> I did RTFM and know that I need to use one of the
> os.exec...commands. But I am confused about the syntax:

I'm actually not too familiar with os.exec(), but have you tried
os.system()?  Here's an example:

###
>>> import os
>>> os.system("ls *.txt")
barfoo.txt  cs3hw2sol.txt  foo.txt
0
###

It's fairly easy to use, and might be just the thing to call fetchmail.  
Good luck!