pyTony
pyMod
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
Use this snippet, it works well http://www.daniweb.com/software-development/python/code/257449 .
Example (with a linux command)
>>> com = Command("ls -l").run()
>>> if com.failed:
... print "ERROR"
... print com.error
... else:
... print com.output
...
total 20
drwxr-xr-x 2 eric eric 4096 2011-09-02 14:35 cons
drwxr-xr-x 10 eric eric 4096 2011-09-08 16:02 img
drwxr-xr-x 4 eric eric 4096 2011-09-05 19:04 notes
drwxr-xr-x 2 eric eric 4096 2011-09-08 20:29 src
drwxr-xr-x 2 eric eric 4096 2011-09-08 20:30 tmp
Gribouillis
Posting Maven
2,786 posts since Jul 2008
Reputation Points: 1,044
Solved Threads: 691