title: How to add new shell commands to a subprocess in Python 3.7?
body: <p>I am trying to find a way to add commands to stdin of an already open shell process in Python 3.7. But I can't seem to find a solution.</p>
  
  <p>I have tried a number of solutions with no luck.</p>
  
  <pre><code>p1 = subprocess.Popen('pwd &gt; test', shell=True, stdin=PIPE, text=True) # works
  
  p1.communicate('pwd &gt; test1')                                    # doesn't work
  p1.communicate(input='pwd &gt; test2')                              # doesn't work
  p1.communicate('pwd &gt; test3\n')                                  # doesn't work
  p1.stdin.write('pwd &gt; test4')                                    # doesn't work
  p1.stdin.write('pwd &gt; test5\n')                                  # doesn't work
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>