I need to automate the following command
cmd="yes | vgremove <vgname>"
whenever I code this command with
Popen(cmd.split(),stdout=PIPE,stderr=PIPE)
it does not complete. I suspect it waits till the command gets complete, so the pipe is struck, is there an alternative for this???
There is a much easier way in this case:
As for your question specifically:
Piping is a shell feature, so you'll need
shell=True
on that. What you're doing withoutshell=True
is executingyes
with arguments.yes
never stops executing so the subprocess never returns.