PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, October 29, 2022

[FIXED] How to send STDIN twice to Popen process, each time with EOF?

 October 29, 2022     eof, popen, python, stdin, subprocess     No comments   

Issue

I have this part of a code:

for stdin in stdins:
    p.stdin.write(stdin)

which writes string stdin to process p's STDIN.

The challenge is: the process p expects to see EOF before it goes to next STDIN.

With the loop above, the problem is that subsequent p.stdin.write(stdin) will be considered by the process p as input of the 1st STDIN input collection. Because, as said earlier, p expect to see an EOF before moving to subsequent fields.

So, my question is: how to solve this problem in Python? The process needs to see something like:

for stdin in stdins:
    p.stdin.write(stdin)
    p.stdin.send_eof()

Constraints: solution must not use pexpect.


Solution

EOF is not a character, it just means there is no more data to read.

As such I don't believe what you're after is possible in Python or most other languages.



Answered By - pishpish
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing