2016-11-08 31 views
0

我有一个简单的例子,我想用nexpect列出文件夹中的所有文件,并在稍后添加expect()功能。Nodejs nexpect:获取所有输出行

nexpect.spawn("ls -la /etc") 
     .run(function (err, output, exit) { 
      res.send(output); 
     }); 

结果,我只是得到一个行:

[email protected] 1 root wheel 11 Oct 2 21:42 /etc -> private/etc 

我的期望是能得到大家的/ etc,因为输出被定义为“输出线的输出{阵}数组审查“(https://github.com/nodejitsu/nexpect)。

作为一个侧面的问题:今天是否值得推荐使用(因为它在一年内没有更新)?

回答

1

这是因为你在Mac上,而/ etc是符号链接。尝试添加/

nexpect.spawn("ls -la /etc/") .run(function (err, output, exit) { res.send(output); });