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
  Pipe traceback to a C program Alexandros 0 1,195 Oct-22-2024, 12:32 PM
Last Post: Alexandros
  Media Pipe Python Interfacing with MATLAB cmcreecc 1 1,549 May-30-2024, 07:23 AM
Last Post: TrentErnser
  Error (Errno 2), File upload with the Flask framework and a public IP Username_Python1 0 2,050 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 5,858 Nov-09-2023, 10:56 AM
Last Post: mg24
  how to write exception error into logger mg24 3 2,671 Nov-15-2022, 04:20 PM
Last Post: insharazzak
  Convert Excel file into csv with Pipe symbol.. mg24 4 3,246 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 2,977 Sep-24-2022, 05:06 PM
Last Post: Gribouillis
  Why is copying and pasting a block now broken? WagmoreBarkless 2 2,715 May-05-2022, 05:01 AM
Last Post: WagmoreBarkless
  Why is copying and pasting a block now broken? WagmoreBarkless 1 2,228 May-04-2022, 11:40 PM
Last Post: Larz60+
  STDIN not working H84Gabor 3 8,284 Sep-06-2021, 08:10 AM
Last Post: H84Gabor

Forum Jump:

User Panel Messages

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