How to mimic passing a file using python variable
<p>I am trying to figure out how to mimic passing a file to a program and instead of passing the file pass a python variable that has what information the program needs in it.</p>

<p>The syntax I need to mimic:</p>

<pre><code>msfconsole &lt; setofcommands.txt 2&gt;/dev/null
</code></pre>

<p>What I would like to do:</p>

<pre><code>answer = os.system('msfconsole &lt; ' + myvariable + ' 2&gt;/dev/null')
</code></pre>

<p>I also would be extremely happy if someone knew how to interact with something like msfconsole over a period of time so that when the msfconsole shell is open I could continually get python to type different commands without have to relaunch a new application for each time I wanted to type a series of commands</p>

<p>Thanks a lot in advance.</p>
