As Andrea said, you should use subprocess.Popen - However, there is no need for advanced text input. You can do this in a separate file, say, "helper.py", which you import into your scripts:
from subprocess import Popen, PIPE def r(cmd_line): return Popen(cmd_line.split(), stdout=PIPE).communicate()[0]
And in other files you can only do
from helper import r print r("ls -l") print r("pwd") r("tar czvf new_tarball.tar.gz %s" % path_to_archive)
Note that this simplified method will not work if you need to go through a space inside the shell command parameter - like the "My Documents" parameter - in this case either use Popen explicitly or improve the helper function, so that it can handle it. Highlighting a white space with "\" will be ignored by the split that I use there.
source share