Reputation: 157
I am facing issue while executing a remote command. If I execute command by logging into remote machine, it works. But if I execute same command from my laptop to remote machine it returns different status code.
Local execution on 192.168.0.166:
root@monica-E470:~# virsh list --state-shutoff | grep Qcow2 | wc -l
1
Remote Command execution:
root@sandipd-ThinkPad-E450:~# ssh [email protected] 'virsh list --state-shutoff | grep Qcow2 | wc -l'
[email protected]'s password:
0
I have tried with different scenarios, but no luck. Has anyone faced same issue?
Upvotes: 0
Views: 283
Reputation: 1081
You have to add a pseudo terminal to execute complex commands in a remote server. Try this instead:
ssh -t [email protected] 'virsh list --state-shutoff | grep Qcow2 | wc -l'
Refer man
page of ssh
for more info.
Upvotes: 2