Can I pass a long bash command to asyncio.subprocess.create_subprocess_exec()?

Viewed 911

Right off the bat, there is a similar question here but it doesn't quite answer my question. I left a comment there just in case though.

In asyncio there is a asyncio.subprocess.create_subprocess_exec coroutine mimicking the more common subprocess.Popen command with shell=False to protect against shell injection. Popen accepts a list of strings but create_subprocess_exec only accepts strings, like

asyncio.subprocess.create_subprocess_exec('ls', '-lah', 'myfile', stdout=..., stderr=..., stdin=...)

I have a bash command as a big string, e.g. s = 'ls -lah myfile'. I want to pass the command to create_subprocess_exec but a list like s.split() doesn't work! How do?

1 Answers
Related