I have a command-line java program that takes a password and it's verification from stdin. Unfortunately, modifying the program isn't an option as it is proprietary.
I'm unable to pass the arguments from the unix command line using < since there are two prompts in the program, both asking for the same password. There are stdout statements asking for "Password" and "Password (validation):" on the command prompt.
How can I pass the password non-interactively to this program so that it can be executed automatically using a cron job / RC script?
Thanks!
2 Answers 2
Chances are that the password is not read from stdin at all, but from /dev/tty. In that case you're out of luck.
Can you run the program by feeding all the input including the passwords through stdin? If not, then you're out of luck.
If this works, however, you can do something like
(echo user; echo passwd1; echo passwd1; cat) | java -jar yourCommandlineprogram.jar