Wednesday, 21 August 2013

How to runCommand() of a bash script with redirected input from file in Mozilla Rhino?

How to runCommand() of a bash script with redirected input from file in
Mozilla Rhino?

Is it possible to execute external bash script and set another file as
input for it using Rhino? e.g. I need to rewrite bash script(exec.sh) with
following content:
somescript.sh <fileInput.txt
I've tried many ways but without success:
Reading fileInput.txt as input stream and passing to shell:
var inputStream = new java.io.InputStream(fileInput.txt);
runCommand( "somescript.sh", inputStream);

Writing "somescript.sh
message = new FileUtils.writeStringToFile(helpfulScript, "somescript.sh
runCommand("bash", helpfulScript.getCanonicalPath());

Sorry for pure highlight and thanks in advice for any ideas.

No comments:

Post a Comment