This is rather a unusual use case where I had to make a legacy system to work.
I have Windows batch script like following named 'batch_test.bat' (example only):
@echo OFF
set /P choice=Enter your choice:
if /I "%choice%" == "N" (
echo "Don't proceed"
)
if /I "%choice%" == "Y" (
echo "Proceed"
)
if /I "%choice%" == "C" (
echo "Cancel"
)
EXIT /B 0
I have following python code (sample):
import os
os.system('batch_test.bat')
Question is how do I feed the choice batch script is expecting from Python? I did some look up but could not find the appropriate answer.
thanks.
os.system: "Thesubprocessmodule provides more powerful facilities… using that module is preferable to using this function…" If you want to control the stdin of a program, or capture its stdout, or run it safely without using the shell, or anything else, usesubprocess, notos.system.subprocessModule, include examples that feed input into other programs, exactly what you haven't been able to find.echo "some text"includes the quotes in the output...