run a shell command in a python script
October 3rd, 2006 by Lawrence David
to execute a shell command in a python script, import the os module:
import os
and then use the popen4 function, which returns file objects corresponding to both stdin and stdout:
(stdin,stdout) = os.popen4(“ls”)
print stdout.read()

Thanks for the information.
It has been helpful for me.
It’s an old comment, but os.popen*() is deprecated in favor of the subprocess module. Far more powerful and will be supported for the foreseeable future.
There’s a very good Examples section in the library reference, your example is covered here: http://docs.python.org/lib/node535.html