Can't get virsh list in node-ssh

143 views Asked by At

app.js:

const fs = require('fs')
const path = require('path')
const {NodeSSH} = require('node-ssh')
const ssh = new NodeSSH()
ssh.connect({
    host: '192.168.0.2',
    username: 'ubuntu',
    password: '123456'
})
.then(function() {
    ssh.execCommand('virsh list --all', {}).then(function(result) {
        console.log(result);
        return;
    })
})

Return:

Id  Name State
--------------------

But the command virsh list --all works and return complete list when using ssh connect via command line. I also test another command in app.js like ls or pwd , and works normally.

Thanks for helping.

1

There are 1 answers

1
Henry Wu On BEST ANSWER

Replace your command with:

bash -l -c "virsh list --all"