im coding a program that starts an command prompt boot application ,at run time of the boot application,the boot application asks many questions like for eg.press 1 to read or 2 to write.but always i'll be reading from the app.i always want to pass 2 to it.but the issue is how should i know that the back ground boot application has asked me a question and that i should reply with appropriate answer dynamically?
Asked
Active
Viewed 801 times
2
-
1Use a redirect to redirect an input file of your making to stdin of the process. – David Heffernan Dec 01 '12 at 11:19
-
See here how set up a two way communication with a console application: [How to send command to console application from GUI application](http://stackoverflow.com/q/2015388/576719). – LU RD Dec 01 '12 at 12:07
-
2What is a 'boot application'? – Sertac Akyuz Dec 01 '12 at 13:23
-
Have you considered using Perl? What you've requested is exactly what the [`Expect`](http://search.cpan.org/~rgiersig/Expect/Expect.pod) library provides. – Rob Kennedy Dec 01 '12 at 20:48
1 Answers
2
If the program reads the input from the standard input then you can create a text file containing your input:
2
Then redirect the standard input to that file:
myapp.exe < inputfile.txt
Perhaps the program has command line options that would also allow you to avoid being prompted.
Note that your question is ambigous. If you are choosing the option to read, shouldn't you input 1?

David Heffernan
- 601,492
- 42
- 1,072
- 1,490