title: Executing Interactive shell script in python
body: <p>I have a shell script with ask for the user input. Consider a below example</p>
  
  <p>Test.sh</p>
  
  <pre><code>#!/bin/bash
  echo -n "Enter name &gt; "
  read text
  echo "You entered: $text"
  echo -n "Enter age &gt; "
  read text
  echo "You entered: $text"
  echo -n "Enter location &gt; "
  read text
  echo "You entered: $text"
  </code></pre>
  
  <p>Script Execution:</p>
  
  <pre><code>sh test.sh
  Enter name&gt; abc
  You entered: abc
  Enter age &gt; 35
  You entered: 35
  Enter location &gt; prop
  You entered: prop
  </code></pre>
  
  <p><em>Now i called this script in python program. I am doing this using sub process module. As far as i know sub process module creates a new process. The problem is when i execute the python script i am not able to pass the parameters to underlying shell script and the scipt is in hault stage. Could some point me where i am doing wrong</em></p>
  
  <p>python script (CHECK.PY):</p>
  
  <pre><code>import subprocess, shlex
  
  
  cmd = "sh test.sh"
  proc = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  stdout,stderr = proc.communicate()
  
  print stdout
  </code></pre>
  
  <p>Python Execution: check.py</p>
  
  <pre><code> python check.py
  </code></pre>