[Tutor] exec* and co.

Viktor Lakics lakicsv@usa.net
Sat, 24 Feb 2001 08:56:18 +0000


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:

1."os.execv('/bin/echo', ['foo', 'bar']" works, prints out only
"bar". Foo is ignored. But "os.execv('ls', ['foo', '-al']" does not
work, gives me an error. Why? What would be the syntax of "ls -al"?
Also I am confused why we need execv execl execlp etc.? 

Could anyone give me a short tutorial how to use these (please give
real life examples, I did RTFM an still confused) I mean how to
invoke "fetchmail -d 2000", "ls -al", "tar xzvf foo.tar.gz", in
general: "command -param -anotherparam file1.txt file2.bak"!?

And please explain WHY is that particular exec* command was used?


TIA :    Viktor