如何解决如何写入Node内产生的交互式R控制台的stdin?
我使用的是Windows 10最新版本的Node.js。
const process = require("child_process");
// Run the R console in interactive mode
r = process.spawn("C:\\Program Files\\R\\R-3.5.2\\bin\\R.exe",["-i"],{ detached: true });
// At this point I can actually see the R shell running
// Make sure to be able to capture output
p.stdout.on('data',function (data) {
console.log("Data is",data.toString());
});
// Write input
p.stdin.write('1 + 0' + require('os').EOL);
但是,我看不到在生成的R shell中写入了任何内容,并且undefined
是回调中的读取值。
我想生成一个进程,并在不同的时间发送不同的输入,并每次获取输出。
我应该如何实现这一目标?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。