tags:

views:

51

answers:

2

Hi All,


Im trying to run a jar file. this jar file will output multiple question in console manner, i want to eliminate the console and i need to input a value in order to proceed.


e.g :
A. Choose value 1 :
[1] Windows
[2] Unix
Input : 2


B. Choose value 2 :
[1] Oracle
[2] DB2
Input : 1


Im trying :
"java -jar program.jar < abc.txt" where
abc.txt has a value of :
2
1
3
etc.
but its not working its only getting the first value. please help. thanks.

btw, ive also try :


OPEN PIPE, "| java -jar program.jar";
open (FH, /abc.txt)
print PIPE "$res";
close FH;
close PIPE;

Regards

+3  A: 

Note sure why your current approach is not working. You may want to take a look at the Expect module on CPAN.

jackrabbit
Thanks guys! will try that. btw, any scripts to see how to use expect? Regards.
The page I linked to contains the documentation for the module. At the end, there are some code examples. The one on how to automate login seems to fit the bill.
jackrabbit
+1  A: 

I reckon the entire contents of the file is being piped all at once to the first prompt, so the remainder of the file just gets 'swallowed' and lost

So, +1 to jackrabbit's suggestion of using the Expect module instead

amir75
Thanks guys! will try that. btw, any scripts to seehow touse expect? Regards.