2016-11-08 35 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); });