Python Forum
getting error "exec_proc.stdin.write(b'yes\n') IOError: [Errno 32] Broken pipe"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getting error "exec_proc.stdin.write(b'yes\n') IOError: [Errno 32] Broken pipe"
#1
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:-
Error:
Traceback (most recent call last): File "sub_process.py", line 32, in <module> multi_executor() File "sub_process.py", line 29, in multi_executor exec_proc.stdin.write(b'yes\n') IOError: [Errno 32] Broken pipe
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error (Errno 2), File upload with the Flask framework and a public IP Username_Python1 0 253 Mar-28-2024, 01:46 PM
Last Post: Username_Python1
  python Read each xlsx file and write it into csv with pipe delimiter mg24 4 1,431 Nov-09-2023, 10:56 AM
Last Post: mg24
  how to write exception error into logger mg24 3 979 Nov-15-2022, 04:20 PM
Last Post: insharazzak
  Convert Excel file into csv with Pipe symbol.. mg24 4 1,325 Oct-18-2022, 02:59 PM
Last Post: Larz60+
  When is stdin not connected to a tty, but can still be used interactively? stevendaprano 1 1,006 Sep-24-2022, 05:06 PM
Last Post: Gribouillis
  Why is copying and pasting a block now broken? WagmoreBarkless 2 1,389 May-05-2022, 05:01 AM
Last Post: WagmoreBarkless
  Why is copying and pasting a block now broken? WagmoreBarkless 1 1,229 May-04-2022, 11:40 PM
Last Post: Larz60+
  STDIN not working H84Gabor 3 3,567 Sep-06-2021, 08:10 AM
Last Post: H84Gabor
  BrokenPipeError: [Errno 32] Broken pipe throwaway34 6 9,249 May-06-2021, 05:39 AM
Last Post: throwaway34
  Duplex Named Pipe with Python Server and C# Clients raybowman 1 2,394 Dec-03-2020, 09:58 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020