trying to pass line info (2 lines reprensting a user and a password) to a java application, the log show that it take the lines but empty value (like only tkae the \n
code is decompiled (only have the copiled version) showing this function and call
public String getUser(String prompt)
{
System.out.print(prompt);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String userName = null;
try
{
return br.readLine();
}
catch (IOException ioe) {
System.out.println("IO error trying to read your name!"); }
return null;
}
call in main code is
try
{
String user = application.getUser("User: ");
User = user;
char[] pswd = application.getPassword(System.in, "Password: ");
if (application.isDebug()) {
application.log("verify User " + User);
}
...
}
else {
application.log("ID not found!");
}
}
catch (Exception e) {
application.log("Exception during login, abort Batch now!");
System.exit(1);
}
calling with different redirection from the shell ex:
printf "%s\n%s\n" "MyUser" "MyPwd" | java SomeArguement Compiledjar
show this in log
User: Password: [2019-09-25 14:06:26 CEST] getUserPlatformContext [2019-09-25 14:06:26 CEST] Exception during login, abort Batch now!
any idea why STDIN in not "read" correctly by this code (this other post confirm it should).
I also put lot more string to pass in case of previous code read STDIN before but it's the same
----------- Other story -----------------------
finaly found the debug argument to pass and it show that the STDIN is correctly read for the user prompt but hang on the getpassword that use a buffer read from another type like ((PushbackInputStream)in).unread(c2)
and failed at this level.