0

I have a simple case where I want to use nexpect to list all files in a folder, and add some expect() functionality later.

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

As a result, I just get one line:

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

My expectation would be to get all of /etc, since output is defined as "output {Array} Array of lines of output examined" (https://github.com/nodejitsu/nexpect).

As a side question: Is nexpect recommendable as of today (since it hasn't been updated in a year)?

benjist
  • 2,740
  • 3
  • 31
  • 58

1 Answers1

1

It's because you are on a Mac, and /etc is a symlink. Try adding a /:

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

Ben Blackburne
  • 320
  • 3
  • 5