I have this piece of code that executes well:
import subprocess
exe_cmd = subprocess.Popen(["ls", "-al"], stdout=subprocess.PIPE)
output, err = exe_cmd.communicate()
print output
And I have another piece where I assign the command to a variable and then pass it as argument. But in this case it fails. Why?
import subprocess
#Here I assign the command to a variable.
cmd = "ls -al"
exe_cmd = subprocess.Popen(cmd, stdout=subprocess.PIPE)
output, err = exe_cmd.communicate()
print output