getting error "exec_proc.stdin.write(b'yes\n') IOError: [Errno 32] Broken pipe" - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: getting error "exec_proc.stdin.write(b'yes\n') IOError: [Errno 32] Broken pipe" (/thread-19995.html) |
getting error "exec_proc.stdin.write(b'yes\n') IOError: [Errno 32] Broken pipe" - Birju_Barot - Jul-23-2019 Hi, We have a framework where we can run multiple python scripts using CLI. Most of the scripts requite user interaction during execution. Now I am trying to automate that thing, so whenever I run python script then it will automatically give user input without user interaction. For that, I have written one sample code. Which is as below:- import subprocess import os import sys import time def multi_executor(): exec_cmd = 'python3.7 '+PATH+sys.argv[2]+' -m '+sys.argv[1]+' -i '+PATH+sys.argv[3]+' -l '+PATH+sys.argv[4]+' -d '+PATH+sys.argv[5] exec_proc = subprocess.Popen(exec_cmd,stdin=subprocess.PIPE,stdout=subprocess.PIPE,shell=True) while True: exec_proc.poll() line = exec_proc.stdout.readline() exec_proc.stdout.flush() if "Enter: Yes or No:" str(line.strip()): exec_proc.stdin.write(b'yes\n') exec_proc.stdin.flush() multi_executor()When I execute the above script then it gives me a broken pipe error. Which is mentioned below:- Here whenever my script tries to give stdin.write input at that time it gives a broken pipe. Please let me know how to solve this issue. And is there any other way to fulfill my requirement then it would be very helpful. |