I'm using a compiled Java file which takes a filename as a parameter and then asks for a username and password (via user input). I am trying to automate this from a shell script, but am running into problems. I'm unable to access the java code, which is why I am having trouble.
So the code is called the following way
java javaprogram /home/user/securityfile
So, you pass the file, and then it asks you for username and password. After entering those, it's done.
Now, I have tried to put the user input into a file and pass it in, but I get an error.
java javaprogram /home/user/securityfile < userinputfile
userinput file contains the following text (First line is the username, second line is the password):
MattSmith
MSpassword136
Does anyone have any ideas? Maybe I am doing it wrong?
Here is the error message:
Exception in thread "main" java.lang.NullPointerException at ilex.util.UserAuthFile.main(UserAuthFile.java:297)
Thanks
straceto see exactly how it's interacting with the console. Note that any mechanism to read a password securely on the console won't work with a pipe; you'll probably need a pty instead.(echo "user"; sleep 1; echo "password") | java javaprogram /home/user/securityfile. If that works you can refactor to read from file without too much work.System.insince it requires an interactive consoleSystem.console(). Some info here.