• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in standalone java returning value to shell script

 
Murthy Manchala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to send password to a shell script to run batch jobs.

I am not able to send password to shell script via java standalone application. the java main method cannot return value as its return type is "VOID". please advice me how i can get password in shell script though java standalone.

Due to security i can't use system out or i can't write to a file.


I saw below code in google but its not working for me
Test.java:



Thanks
Murthy
 
Murthy Manchala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i use above code and run the script as

./test.sh

Its not showing any thing.

Thanks
Murthy.
 
Rob Spoor
Sheriff
Pie
Posts: 20494
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's because the only way to make any Java output anything is using System.out, System.err or System.console() (if available). However, you're explicitly forbidden to use any of these. Therefore you simply cannot do what you need to do.

It's like asking you to tighten a screw without letting you use a screw driver, coin or anything else you can use to tighten a screw.
 
Murthy Manchala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,

Due to security reasons i can't use system.out or system.err. I should not print the password. is there any way i can get the password in shell script.


Thanks in advance.
 
Henry Wong
author
Marshal
Pie
Posts: 20882
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Murthy Manchala wrote:
Due to security reasons i can't use system.out or system.err. I should not print the password. is there any way i can get the password in shell script.


It's pretty simple. If the password can't leave the java program -- system out, files, network, etc. -- it can't get to the shellscript.

Your best option is to move (port) the code that needs the password (in the shellscript), into the java program.

Henry
 
Murthy Manchala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry,

except the system.out what are the options i have. I can't write password to a file. is the system.set property works. if it works can you please give me sample code

Thanks
 
Henry Wong
author
Marshal
Pie
Posts: 20882
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Murthy Manchala wrote:is the system.set property works. if it works can you please give me sample code


No. Shellscripts runs programs in a subshell, so environment variables won't take.... and even if you could, don't the same security restrictions (intent) apply?

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic