Skip to main content
added 7 characters in body
Source Link
Hauke Laging
  • 94.5k
  • 21
  • 132
  • 185

Please note, I did not write any of these script, Java code, or the application and I am restricted as to what I can modify in these scripts.

I have a Bash script that starts a Java console /foo/bar/myscript.sh/foo/bar/myscript.sh. Specified inside, it calls to start the Java console but prompts for a password before the shell is launched. I am trying to pass a command into the Java console that executes a backup procedure for an application.

Is there a way to run the script which passes the password? The password is not set via Bash but somewhere in Java and I don't know the variable name.

Is there also a way to pass the Java method in the same line? This is the normal, manual process:

  1. ./myScript.sh
  2. Please enter password: myPassword
  3. javaConsole % backup.method("/backup/dir");

Obviously this isn't correct but ideally, a command would go like this:
echo myPassword | ./myscript.sh | backup.method("/backup/dir");

Please note, I did not write any of these script, Java code, or the application and I am restricted as to what I can modify in these scripts.

I have a Bash script that starts a Java console /foo/bar/myscript.sh. Specified inside, it calls to start the Java console but prompts for a password before the shell is launched. I am trying to pass a command into the Java console that executes a backup procedure for an application.

Is there a way to run the script which passes the password? The password is not set via Bash but somewhere in Java and I don't know the variable name.

Is there also a way to pass the Java method in the same line? This is the normal, manual process:

  1. ./myScript.sh
  2. Please enter password: myPassword
  3. javaConsole % backup.method("/backup/dir");

Obviously this isn't correct but ideally, a command would go like this:
echo myPassword | ./myscript.sh | backup.method("/backup/dir");

Please note, I did not write any of these script, Java code, or the application and I am restricted as to what I can modify in these scripts.

I have a Bash script that starts a Java console /foo/bar/myscript.sh. Specified inside, it calls to start the Java console but prompts for a password before the shell is launched. I am trying to pass a command into the Java console that executes a backup procedure for an application.

Is there a way to run the script which passes the password? The password is not set via Bash but somewhere in Java and I don't know the variable name.

Is there also a way to pass the Java method in the same line? This is the normal, manual process:

  1. ./myScript.sh
  2. Please enter password: myPassword
  3. javaConsole % backup.method("/backup/dir");

Obviously this isn't correct but ideally, a command would go like this:
echo myPassword | ./myscript.sh | backup.method("/backup/dir");

Source Link
Greg
  • 187
  • 5
  • 11

Pass input into Java console launched by a Bash script

Please note, I did not write any of these script, Java code, or the application and I am restricted as to what I can modify in these scripts.

I have a Bash script that starts a Java console /foo/bar/myscript.sh. Specified inside, it calls to start the Java console but prompts for a password before the shell is launched. I am trying to pass a command into the Java console that executes a backup procedure for an application.

Is there a way to run the script which passes the password? The password is not set via Bash but somewhere in Java and I don't know the variable name.

Is there also a way to pass the Java method in the same line? This is the normal, manual process:

  1. ./myScript.sh
  2. Please enter password: myPassword
  3. javaConsole % backup.method("/backup/dir");

Obviously this isn't correct but ideally, a command would go like this:
echo myPassword | ./myscript.sh | backup.method("/backup/dir");