title: How to read python subprocess stdout without communicate
body: <p>I have a python 3 script that accepts input from the user, this input is piped into a subprocess, where a shell has been spawned. Originally I was going to put this code together with a socket, to be able to make my own non-serious remote administration tool, however this proves too hard for my level currently. Code:</p>
  
  <pre><code>import subprocess
  
  p1 = subprocess.Popen(["/bin/sh"], stderr = subprocess.PIPE, stdin = subprocess.PIPE, stdout = subprocess.PIPE, encoding = "utf-8")
  
  command = input("Command: ")
  
  p1.stdin.write(command)
  
  p1.stdout.read()
  </code></pre>
  
  <blockquote>
    <p>Problem: Nothing gets printed out. I have searched endless hours
    online for a reason, over multiple days, but all of them don't seem to
    work, and/or advise using communicate() which is something I do not
    want to do. When thinking ahead if I am able to implement this with a
    socket, I can't have the process closing after each command. I have
    also tried flushes everywhere, before write, inbetween the read, after
    the read, pretty much everywhere you can think of. It should be simple
    enough, without me having to look deep into the io module or the rules
    of buffering (too late now). I have been struggling with this for days
    on end.</p>
  </blockquote>