| | |
Executing DOS batch files in Python
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 5
Reputation:
Solved Threads: 0
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
Prachu
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
Prachu
•
•
Join Date: Apr 2008
Posts: 5
Reputation:
Solved Threads: 0
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...
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 ...
Sorry, line one comes out a little goofy. Toggle to plain text to see the correct line.
python Syntax (Toggle Plain Text)
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])
Last edited by vegaseat; Apr 17th, 2008 at 2:04 pm.
May 'the Google' be with you!
•
•
•
•
Hi..
i tried this...its behaving in the same way as the os.system did..
Hi .. ! U can do it like this
Python Syntax (Toggle Plain Text)
import os os.system('install-nt.bat %s %s %s < %s'%(input1,input2,input3,'C:\command.txt'))
Hope this works [
]- Mohan
![]() |
Other Threads in the Python Forum
- Previous Thread: help - keyboard controls/character not moving
- Next Thread: problems with menu and main functions-correctly indented.
| Thread Tools | Search this Thread |
Tag cloud for Python
ansi assignment avogadro backend beginner binary bluetooth character cmd code customdialog cx-freeze data decimals dictionary drive dynamic error examples excel exe file float format ftp function gnu graphics gui heads homework http ideas import input java leftmouse line linux list lists logging loop module mouse number numbers output parsing path pointer port prime program programming progressbar projects push py2exe pygame pyqt python random recursion recursive refresh schedule screensaverloopinactive script scrolledtext sqlite ssh statistics stdout string strings sudokusolver sum table terminal text thread threading time tkinter tlapse tricks tuple tutorial ubuntu unicode update urllib urllib2 variable wikipedia windows write wxpython xlib






