executing a command
andrea valle
marta_andrea at tele2.it
Sat Jun 4 03:43:15 EDT 2005
Hi to all,
I need to run a program from inside python (substantially, algorithmic
batch processing).
I'm on mac osx 10.3.8 with python 2.3 framework and macpython.
Trying to use exec*, I checked references, Brueck & Tanner, and then
grab this code from effbot:
>>> program = "python"
>>> def run(program, *args):
os.execvp(program, (program,) + args)
print "ok"
>>> run("python", "/Users/apple/Desktop/prova.py")
Traceback (most recent call last):
File "<pyshell#50>", line 1, in -toplevel-
run("python", "/Users/apple/Desktop/prova.py")
File "<pyshell#49>", line 2, in run
os.execvp(program, (program,) + args)
File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/os.py", line 336, in execvp
_execvpe(file, args)
File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/os.py", line 374, in _execvpe
func(fullname, *argrest)
OSError: [Errno 45] Operation not supported
This OSError seems to be consistend with all exec family. What does it
mean and how to use exec?
I also tried with. os.system. It works if I invoke python, but it fails
(in a way I don't know) when I invoke other programs.
For example:
command = "python /Users/apple/Desktop/test.py"
>>> os.system(command)
0
(test.py write a string in a file. It works)
But with lilypond or with latex I have no output (and in fact it
doesn't give 0 as result):
>>> command = "lilypond /Users/apple/Desktop/test.ly"
>>> os.system(command)
32512
>>> command = "latex /Users/apple/Desktop/test.tex"
>>> os.system(command)
32512
Any help is much appreciated
Thanks a lot
-a-
More information about the Python-list
mailing list