【发布时间】:2013-06-25 16:51:04
【问题描述】:
我是 node.js 的新手,并试图连续执行两个进程,第一个进程的标准输出通过管道传输到第二个进程的标准输入。然后第二个进程的标准输出应该通过管道传输到变量 res 作为对 URL 请求的响应。代码在这里。部分是别人写的,可能我有什么误解:
var sox = spawn("sox", soxArgs)
var rubberband = spawn("rubberband", rubberbandArgs)
sox.stdout.pipe(rubberband.stdin)
rubberband.stdout.pipe(res) #won't send to res anything, why?
#rubberband.stdin.pipe(res) won't send to res anything, either!
#sox.stdout.pipe(res) will work just fine
sox.stdin.write(data)
sox.stdin.end()
#the actual sox process will not execute until sox.stdin is filled with data..?
任何帮助将不胜感激!我花了几个小时研究这个!
【问题讨论】:
-
你看文档了吗?
-
@Nirk 我读过nodejs.org/api/…,但不确定这是否解决了我的问题。有什么想法吗?
-
也希望有一些有用的方法来调试这个东西..
-
阅读nodejs.org/api/… -- 它给出了
ps ax | grep ssh的完整示例 -
我有点困惑,哪个先运行,哪个需要输出作为响应。