views:

278

answers:

2

Hello,

I have a console program ( a DOS program) that requires interactive input. After typing in the command line, for example

commandline.exe /ShowReport

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

And I would press '1' if I want to show report A.

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? Thanks

A: 

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.

Martin Cote
A: 

Not strictly a batch solution but this might do the trick: Expect

See also the Wikipedia entry.

Steph