Why process = subprocess.Popen(command, stdout=subprocess.PIPE) is not working for such command?
['docker', 'exec', 'hungry_keller', 'bash', '-c', ' ""ls -l""] docker exec hungry_keller bash -c "ls -l"
and returns: No such file or directory
subprocess.check_output returns the same error.
but in terminal it executes correctly. More simple commands are working fine.
You've been overzealous with your quoting. When you type at the shell prompt
bash -c "ls -l", you're using the quotes to tell bash thatls -lis a single token. Those quotes aren't actually seen bybashat all; it simply receives two arguments:-cls -lWhen calling
subprocessmethods with a list, you're already being explicit about your tokenization because you're providing a list of strings. So instead of:You want: