Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用Mozilla Rhino中文件的重定向输入运行bash脚本的Command()?_Javascript_Bash_Rhino - Fatal编程技术网

Javascript 如何使用Mozilla Rhino中文件的重定向输入运行bash脚本的Command()?

Javascript 如何使用Mozilla Rhino中文件的重定向输入运行bash脚本的Command()?,javascript,bash,rhino,Javascript,Bash,Rhino,是否可以执行外部bash脚本并使用Rhino设置另一个文件作为输入? e、 g.我需要用以下内容重写bash脚本(exec.sh): somescript.sh <fileInput.txt somescript.sh您需要将输入流作为对象的input属性传入 var inputStream = new java.io.FileInputStream("fileInput.txt"); runCommand("somescript.sh", { input: inputStream })

是否可以执行外部bash脚本并使用Rhino设置另一个文件作为输入? e、 g.我需要用以下内容重写bash脚本(exec.sh):

somescript.sh <fileInput.txt

somescript.sh您需要将输入流作为对象的
input
属性传入

var inputStream = new java.io.FileInputStream("fileInput.txt");
runCommand("somescript.sh", { input: inputStream });

如果
input
不是
InputStream
,它将转换为字符串并直接发送到命令。类似地,您可以添加
output
和/或
err
属性来捕获命令的标准输出和标准错误()。

Perfect!顺便说一句,文档没有规定流应该如何传递;(