Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get output string parameter from Java to shell script

 
Eung maeng
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Does anyone know how to get output string parameter from Java to shell script. which means when shell script execute a java with input string parameter(20 bytes) and Java program return an output string parameter.

is that possible to return a string to sell script?
if so, how java can return and how to retrieve this string output value from shell script progtam.

welcome any opinion,

thanks,
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really a String per se, but you can get at the output stream of the script process; that's pretty close to being the same thing. See here for hints on how to proceed.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand the question the other way round, Ulf.

Sending 20 bytes to Java can be done in two ways: As inputstream or by arguments.

Method 1:


call it:


grab the output in the shell:


Using a parameter works this way:


and is called

simply using

will not work, since date responds with
Sa 15 Dez 21:14:37 CET 2007
which is 6 Strings (seperated by whitespace).
Masking them with "..." glues them together with blanks inside.
If your bytes aren't printable, it might be useful as well to mask them.

grab the output in the shell:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic