Javascript 如何使用Mozilla Rhino中文件的重定向输入运行bash脚本的Command()?
是否可以执行外部bash脚本并使用Rhino设置另一个文件作为输入? e、 g.我需要用以下内容重写bash脚本(exec.sh):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 })
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!顺便说一句,文档没有规定流应该如何传递;(