Run a python script inside a running program
<p>I am running a python script that launches a executable called ./abc This executable enters inside of a program and waits for a command like so:</p>

<pre><code>$./abc
abc &gt;                      \\waits for a command here.
</code></pre>

<p>What I would like to do is to enter a couple of commands like:</p>

<pre><code>$./abc
abc &gt; read_blif alu.blif
abc &gt; resyn2
</code></pre>

<p>What I have so far is as follows:</p>

<pre><code>import os
from array import *

os.system('./abc')
for file in os.listdir("ccts/"):
    print 'read_blif ' + file + '\n'
    print 'resyn2\n'
    print 'print_stats\n'
    print 'if -K 6\n'
    print 'print_stats\n'
    print 'write_blif ' + file.split('.')[0] + 'mapped.blif\n'
</code></pre>

<p>This however will do the following:</p>

<pre><code>abc &gt;                 \\stays idle and waits until I ^C and then it prints
read ...blif
resyn2
...
</code></pre>

<p>It prints just to the terminal. How do I make it execute this inside the program and wait until it sees the next abc > to run the next command.
Thanks</p>