3

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

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 
Sign up to request clarification or add additional context in comments.

2 Comments

Looks like you're correct - It passes all arguments to the first prompt and I also end up with the "stty: standard input: Invalid argument"exception
This is when it trys to set noecho mode.
1

Not sure by your question if Expect is acceptable or not.

1 Comment

It's definitely an option but I was hoping to solve the issue without having to install additional RPMs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.