Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python stdin eof

Tags:

python

stdin

eof

How to pass python eof to stdin

here is my code

p = Popen(commd,stdout=PIPE,stderr=PIPE,stdin=PIPE)
o = p.communicate(inputstring)[0]

when i run the commd in command line after i input the inputstring windows still expecting a Ctrl+Z to finish accepting input.

How can I pass eof or Ctrl+Z in program?

Thanks!

like image 256
icn Avatar asked Jun 16 '26 09:06

icn


1 Answers

p.stdin.close()

after p.communicate, finishes the input and sends EOF to commd.

like image 157
fserb Avatar answered Jun 18 '26 22:06

fserb