Running on Windows, the following Python program produces the above output (the content of the output variable)
import commands
cmd = "dir"
(output) = commands.getoutput(cmd)
print output
Very interesting and frustrating. Can someone point me to the explanation please?
See the documentation:
Which is where the
{are coming from. You should usesubprocessinstead.The
shell=Trueis required in this specific case as dir is an internal DOS command. Normally one should provide full path to the executable and keep shell disabled.