Executing a program
klappnase
klappnase at freenet.de
Sat Jul 19 19:16:14 EDT 2003
Eirik <hannibalkannibal at yahoo.no> wrote in message news:<FTeSa.7289$os2.110498 at news2.e.nsc.no>...
> Greetings!
>
> How can I run a program from within Python?
>
> I have tried the exec* family of functions, but I get these strange
> errors, like this:
>
> Exception in Tkinter callback
> Traceback (most recent call last):
> File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 1300, in __call__
> return apply(self.func, args)
> File "./PPP", line 9, in run_app
> os.execvp("home/eirik/ppp-skript", argument)
> File "/usr/lib/python2.2/os.py", line 298, in execvp
> _execvpe(file, args)
> File "/usr/lib/python2.2/os.py", line 324, in _execvpe
> apply(func, (file,) + argrest)
> OSError: [Errno 2] No such file or directory
Hi,
if you want to run an external program with a bash command (seems like
that's what you're trying to do) exec is not the right function for
you; with exec you can run python modules.
Try something like:
os.system("home/eirik/ppp-skript --argument")
instead or if you want to get the output of your program try
xyz = commands.getoutput("home/eirik/ppp-skript --argument")
Did that help (maybe I have not really understood your problem)?
Cheers
Michael
More information about the Python-list
mailing list