<br><br>
<div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">tarun</b> <span dir="ltr"><<a href="mailto:tarundevnani@gmail.com">tarundevnani@gmail.com</a>></span><br>Date: Wed, Apr 8, 2009 at 10:30 AM<br>
Subject: Fwd: Issue with subprocess Module<br>To: <a href="mailto:bangpypers@python.org">bangpypers@python.org</a><br><br><br>
<div>
<div></div>
<div class="h5"><br><br>
<div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">tarun</b> <span dir="ltr"><<a href="mailto:tarundevnani@gmail.com" target="_blank">tarundevnani@gmail.com</a>></span><br>
Date: Tue, Apr 7, 2009 at 4:34 PM<br>Subject: Issue with subprocess Module<br>To: <a href="mailto:python-list@python.org" target="_blank">python-list@python.org</a><br><br><br>
<div>Hello All,</div>
<div> </div>
<div>I've a batch file to be invoke using a python script. The batch file has pause, and the time, I need to send some command to the batch file from my scripts. I placed both, the batch file (test.bat) and the python script (test.py) in the same folder. And executed 'test.py'</div>
<div> </div>
<div>(Please find the source files and error below). </div>
<div> </div>
<div><strong>I get the following error:</strong></div>
<div><font color="#cc0000" face="courier new,monospace">Traceback (most recent call last):<br> File "<string>", line 74, in run_nodebug<br> File "D:\test.py", line 4, in <module><br> proc = subprocess.Popen(my_bat,stdin=subprocess.PIPE)<br>
File "C:\Python25\lib\subprocess.py", line 588, in __init__<br> errread, errwrite) = self._get_handles(stdin, stdout, stderr)<br> File "C:\Python25\lib\subprocess.py", line 717, in _get_handles<br>
c2pwrite = self._make_inheritable(c2pwrite)<br> File "C:\Python25\lib\subprocess.py", line 746, in _make_inheritable<br> DUPLICATE_SAME_ACCESS)<br>WindowsError: [Error 6] The handle is invalid</font></div>
<div> </div>
<div><strong>Python Script:</strong></div>
<div><u><font color="#6633ff" face="courier new,monospace">test.py</font></u></div>
<div><font color="#6633ff" face="courier new,monospace">import subprocess,os<br>my_bat = os.getcwd()+'\\test.bat'</font></div>
<div><font color="#6633ff" face="courier new,monospace">proc = subprocess.Popen(my_bat,stdin=subprocess.PIPE)<br>input = '\n'<br>proc.communicate(input)</font></div>
<div> </div>
<div><strong>Batch File</strong></div>
<div><u><font color="#3333ff" face="courier new,monospace">test.bat</font></u></div>
<div><font color="#3333ff" face="courier new,monospace">echo "START'<br>pause<br>echo 'END'</font><br></div>
<div>Please help me with this issue. </div>
<div> </div>
<div>Thanks In Advance,</div>
<div>Tarun</div></div><br></div></div></div><br>