Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ProcessBuilder Sending Multiple Commands, avoiding Shell

807588May 20 2009 — edited May 20 2009
Working on Linux, I have a program which can be called from the command line with a given file, the file contains a list of commands:
aProgram < aFile
For the last year or so I have used ProcessBuilder & StreamGobbler etc to execute the command as:
String cmd = new String[]{"/bin/sh","-c","aProgram < aFile"};
.......
.......
Works fine. But I would prefer to not to use shell, Is it possible to call the program stand alone and pass the file into the program via a Stream. I've tried writing to outputStream but no success.
String cmd = new String[]{"aProgram"};
.....
Thanks for any hints?

Edited by: rbp_osborne on May 20, 2009 9:24 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 17 2009
Added on May 20 2009
15 comments
3,666 views