Is there anyway to script though a bash script or something alike the
user input to a java process..?
I tried something like
echo "Starting..."
bash /opt/dir/myjavaprocess << EOF
test1
test2
test3
It always seems to just get the first line and then have a lot of
returns or something?
I also tried
(echo "test 1\
test2\
test3
| /opt/dir/myjavaprocess)
and it seemed to do the same thing?
John B. Matthews - 27 Sep 2008 02:23 GMT
In article
<602a6f77-0938-4e99-998d-344e8604ec3d@k36g2000pri.googlegroups.com>,
> Is there anyway to script though a bash script or something alike the
> user input to a java process..?
[quoted text clipped - 18 lines]
>
> and it seemed to do the same thing?
<console>
$ javac FilterStream.java ; java FilterStream < FilterStream.java
/**
* Copy stdin to stdout, byte by byte.
* @author John B. Matthews
*/
import java.io.*;
public class FilterStream {
public static void main(String[] args) throws IOException {
BufferedInputStream in = new BufferedInputStream(System.in);
int c;
while ((c = in.read()) != -1) {
System.out.write(c);
}
}
}
$ cat test.sh
#!/bin/sh
java FilterStream << EOF
one
two
three
EOF
$ ./test.sh
one
two
three
</console>

Signature
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
Nigel Wade - 29 Sep 2008 14:33 GMT
> Is there anyway to script though a bash script or something alike the
> user input to a java process..?
[quoted text clipped - 18 lines]
>
> and it seemed to do the same thing?
What is /opt/dir/myjavaprocess? You are running it with bash which would suggest
that its a shell script, but what does it do?
Using hereis input redirection works with java and a simple script which runs
java. Perhaps your shell script is messing with the input stream.

Signature
Nigel Wade