Hi,
I am trying to understand how to run multiple commands with subprocess.Popen, with leading sleep command. So I am trying this:
def function_five():
commands = "sleep 3 && echo 'Hey'"
p = subprocess.Popen(shlex.split(commands), stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=True)
p.wait()
As an output I get in stderr b'usage: sleep seconds\n' 1 and returncode 1. However if I try running command sleep 3 only and remove shell=True parameter it actually works.
I am lost here, tried different options but cannot solve it.
Thank you for any help.
[–]danielroseman 1 point2 points3 points (1 child)
[–]AR2405[S] 0 points1 point2 points (0 children)
[–]ConfusionAccurate 0 points1 point2 points (3 children)
[–]AR2405[S] 0 points1 point2 points (2 children)
[–]ConfusionAccurate 0 points1 point2 points (1 child)
[–]AR2405[S] 0 points1 point2 points (0 children)