Python System Calls: Difference between revisions
Jump to navigation
Jump to search
Created page with '== Backquotes == <source lang="python"> output = `dmesg | grep hda` </source> == os.popen == <source lang="python"> import os cmd = "medcon -f %s" % fileName output = os.popen(cā¦' |
(No difference)
|
Revision as of 22:30, 1 February 2011
Backquotes
output = `dmesg | grep hda`
os.popen
import os
cmd = "medcon -f %s" % fileName
output = os.popen(cmd)
for line in output:
#do something with line
subprocess module (Python 2.4+)
from subprocess import *
cmd = "medcon -f %s" % fileName
output = Popen(cmd, shell=True, bufsize=512, stdout=PIPE).stdout
for line in output:
#do something with line
The os.shutil module
Used for copying, moving, and deleting files and directories:
os.listdir(path)