Search code examples
pythonsubprocesspopenwhiptail

How to write EOF to STDIN popen in python


I have the following command run through popen:

p = subprocess.popen(["/usr/bin/whiptail", "--title", "\"Progress\"", "--gauge", "\"\"", "6", "50", "0"], stdout=subprocess.PIPE, stding=subprocess.PIPE)

To stop the whiptail command from running I need to send EOF to stdin.

How do I send EOF to stdin in Python ?

or I just call p.terminate()


Solution

  • What you need is to close the file used as standard input for your script.

    So in your case it's p.stdin.close().