user353660
user353660

Reputation: 21

running jar file with multiple arguments in perl


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

Upvotes: 2

Views: 603

Answers (2)

laher
laher

Reputation: 9110

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

Upvotes: 1

jackrabbit
jackrabbit

Reputation: 5663

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

Upvotes: 3

Related Questions