wood burning stoves 2.0*
The moose likes Linux / UNIX and the fly likes Pass parameters from shell to java stdin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Pass parameters from shell to java stdin" Watch "Pass parameters from shell to java stdin" New topic
Author

Pass parameters from shell to java stdin

Geraldine Premkumar
Greenhorn

Joined: May 01, 2006
Posts: 5
Hi

I have a shell script that calls java program. I need to pass parameters not as command line arguments to the java program but to java's standard input. Is there a way to do this in the shell script. I do know that < redirects I/O but how do I apply it here since I want to send only specific parameters and not the entire contents of the file.
I am very new to shell scripts and really appreciate any pointers.

Thanks
Geraldine
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16022
    
  20

I think a "here script" is what you'd like:

java myprogram <<END
$PARAM_1
$PARAM_2
$PARAM_3
END

Everything between the delimiters ("END") is piped into stdin, with shell subsistutions being done as required.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Pass parameters from shell to java stdin