Reputation: 190
I am trying to automate a process. If I run the command "nexec -i $HOST cash status" manually i see the expected results. However, when using a python script and running the command as below:
p = subprocess.Popen(command, stdout = subprocess.PIPE, shell=True)
runningAppString, err = p.communicate()
the script hangs because a prompt appears asking what type of login the user wants to login as. I can solve that by opening a stdin PIPE and p.communicate(input="3") but I dont understand why this is happening. Additionally, when I first started working on the script last week IIRC it was working just fine with only the stdout pipe. Why does this happen and what is the best way to deal with it?
Upvotes: 1
Views: 257
Reputation: 10015
Try splitting the command into an array:
p = subprocess.Popen(["nexec", "-i", "$HOST", "cash", "status"])
Upvotes: 1