Aufrufende app von Teilprozess.Aufruf mit Argumenten

Ich bin ein Anfänger in Python und ich habe versucht, rufen Sie ein Kommandozeilen-app, aber es scheitert:

>>> import subprocess as s
>>> s.call("gpio -g read 17")
Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python2.6/subprocess.py", line 470, in call
        return Popen(*popenargs, **kwargs).wait()
    File "/usr/lib/python2.6/subprocess.py", line 623, in __init__
        errread, errwrite)
    File "/usr/lib/python2.6/subprocess.py", line 1141, in _execute_child
        raise child_exception
OSError: [Errno 2] No such file or directory

Aber dann wenn ich auf add shell=True es beginnt zu arbeiten. Kann mir jemand erklären, warum?

>>> import subprocess as s
>>> s.call("gpio -g read 17", shell=True)
>>> 0

InformationsquelleAutor der Frage Mark Ingram | 2012-08-03

Schreibe einen Kommentar