0

I am using ssh2 to execute ls -1 command on remote computer and get response like byte array. I convert to string with function

function ab2str(buf) {
  return String.fromCharCode.apply(null, new Uint16Array(buf));
}

but when I try to split resulted/converted string by newline it doesn't work. (I have tried and asked on stackoverflow how to split and tried all solutions but it doesn't work, different results like add \ at the beginning and similar but doesn't split). I think maybe I convert on wrong way. Did anyone use ssh2 for return and how to convert that array to string.

PaolaJ.
  • 10,872
  • 22
  • 73
  • 111

1 Answers1

0

Use Buffer.toString() method on your buf

Andrey Sidorov
  • 24,905
  • 4
  • 62
  • 75