【问题标题】:Nodejs nexpect: Get all output linesNodejs nexpect:获取所有输出行
【发布时间】:2023-03-29 04:35:01
【问题描述】:

我有一个简单的案例,我想使用 nexpect 列出文件夹中的所有文件,然后添加一些 expect() 功能。

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

结果,我只得到了一行:

lrwxr-xr-x@ 1 root wheel 11 Oct 2 21:42 /etc -> private/etc

我的期望是获取所有 /etc,因为输出被定义为“输出 {Array} 已检查的输出行数组”(https://github.com/nodejitsu/nexpect)。

作为一个附带问题:从今天开始是否值得推荐(因为它已经一年没有更新了)?

【问题讨论】:

    标签: node.js nodejitsu


    【解决方案1】:

    这是因为您使用的是 Mac,而 /etc 是一个符号链接。尝试添加/

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-21
      • 1970-01-01
      相关资源
      最近更新 更多