Hi all..

I am new to Python and badly need help...I am trying to run a DOS batch file from Python..I have given the inputs also..It runs half and then exits at the point of time when I need to give answer to whether I need to replace two files or not...when that interrupt comes up the batch file just closes and no error is logged...how do I get to give that user input in the middle...is it possible???Is there any way that the python would prompt us to enter the values???
Thanks in advance

Recommended Answers

All 7 Replies

Have you looked at popen2? It's documented in the Python run-time library manual and I'm sure google will show lots of examples.

i am sorry but I am not able to execute that command as a sub-process as it says in the library reference...i have been using the following code :
os.system('C:\\Python25\\Test\\LH-Sitekit\\sitekit\\engine\\install-nt.bat %s,%s,%s'%(input1,input2,input3))
where the 3 inputs are defined previously...

Please could u let me know how to use popen2() with this cmd...

Try something like this ...

program = "C:\\Python25\\Test\\LH-Sitekit\\sitekit\\engine\\install-nt.bat"
# supply the proper input values as strings
input1 = 'x'
input2 = 'x'
input3 = 'z'

import subprocess
subprocess.call([program, input1, input2, input3])

Sorry, line one comes out a little goofy. Toggle to plain text to see the correct line.


i tried this...its behaving in the same way as the os.system did.. :(


i tried this...its behaving in the same way as the os.system did.. :(

Hi .. ! U can do it like this

import os

os.system('install-nt.bat %s %s %s < %s'%(input1,input2,input3,'C:\command.txt'))

Hope this works [:P]

- Mohan :) :P

Thanks a lot! It works! :)

input1 input2 input 3, what are those???

someone can expland to me:D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.