• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem in standalone java returning value to shell script

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If i use above code and run the script as

./test.sh

Its not showing any thing.

Thanks
Murthy.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic