Just wondering if anybody could tell me why
import subprocess, commands
p=subprocess.Popen(["ls", "*00080"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output=p.communicate()[0]
print "o", output
result=commands.getoutput("ls *00080")
print "o", result
gives the outputs:
o ls: cannot access *00080: No such file or directory
o 010.010.013.165.42974-010.010.013.164.00080
Both should find the file shouldn’t they?
A
commandsspaws a shell which does the glob expansion.subprocessdoesn’t spawn a shell unless you passshell = True.In other words:
should do the same thing that
commandsdid.