批处理脚本以使用选项使DOS程序自动化 [英] Batch Script to Automate a DOS Program with Options
问题描述
我有一个需要交互式输入的控制台程序(DOS程序)。在命令行中输入后,例如
I have a console program ( a DOS program) that requires interactive input. After typing in the command line, for example
commandline.exe /ShowReport
DOS提示符将提示用户键入一些值,然后继续进行下一个交互式输入。
The DOS prompt will prompt user to key in some values, and then proceed to the next interactive input.
例如,当我键入上述命令时,控制台将提示我以下选项:
For example, when I typed in the above command, the console will prompt me with the following options:
press '1' to show Report A
press '2' to Show Report B
现在的问题是我想通过在脚本文件中预置所有输入值来自动执行所有这些操作。也许像这样(我不知道)
The issue now is I want to automate all these things by presetting all the input values in a script files. Maybe something like this ( I don't know)
commandline.exe /ShowReport <1<'abc'
我想为此编写一个批处理脚本。有什么工具可以帮助我做到这一点?
I want to write a batch script for this. Is there any tools that allow me to do that?
推荐答案
您可以将所有输入内容写到文件中(例如'input.txt'),并使用重定向将程序输入这些输入:
You could write all your inputs in a file (say 'input.txt') and use redirection to feed your program with these inputs:
commandline.exe /ShowReport < input.txt
'<'告诉命令提示符使用文件上的内容右侧作为标准输入。
The '<' tells the command prompt to use the content of the file on the right hand side as standard input.
这篇关于批处理脚本以使用选项使DOS程序自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!