node-ssh icon indicating copy to clipboard operation
node-ssh copied to clipboard

cwd not support ~

Open zgpio opened this issue 3 years ago • 1 comments

ssh.execCommand('pwd', { cwd:  '~/server/bin' }).then(function(result) {
    console.log('STDOUT: ' + result.stdout)
    console.log('STDERR: ' + result.stderr)
})

result in cd '~/server/bin' ; pwd then goto error: bash: line 0: cd: ~/server/bin: No such file or directory

zgpio avatar Sep 14 '22 03:09 zgpio

It's a limitation coming from the way things work, cannot help much in this regard without complicating things a lot.

One alternative in this situation would be to spawn a shell, execute this command in there, and then print pwd. Try running (with exec) 'bash', ['-c', 'cd ~/server/bin', 'pwd'] and tell me if that works

steelbrain avatar Sep 14 '22 08:09 steelbrain