如何写入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 (将#修改为@)