wojtekM
wojtekM

Reputation: 1

Paramiko ssh connection to windows host. Empty stdout of "VBoxManage.exe guestcontrol run" command

I'm writing python script executing bash script inside virtualbox VM using paramiko python library. The code snippet below:

stdin, stdout, stderr = i[2].exec_command("\"\Program Files\Oracle\VirtualBox\VBoxManage.exe\" guestcontrol \"virtnet_proxy\" run --exe \"/home/username/show_ip.sh\" --username username --password password" )
exit_status = stdout.channel.recv_exit_status()          

if exit_status == 0:
    proxy_ip=stdout.readlines()
    print ("got proxy ip from host  ", i[0], proxy_ip, stderr.readlines())

Connects to windows host and should print ip address of a VM's interface. If you run this command in cmd it works fine but using paramiko ssh client, stdout is empty. If you run similar code except you connect to linux virtualbox host (and run linux command) stdout.readlines() works fine and contains output of bash script. Stderr output:

VBoxManage.exe: warning: Error getting stdout handle: VERR_NOT_IMPLEMENTED\r\n', 'VBoxManage.exe: warning: Error getting stderr handle: VERR_NOT_IMPLEMENTED\r\n

Bash script:

ips=$(hostname --all-ip-addresses)
read -ra arr <<< "$ips"
echo"${arr[0]}"

As i said stdout is empty only if you connect to windows host and run vboxmanage command on guest machine.

Thank You in advance, Wojtek

Upvotes: 0

Views: 330

Answers (1)

wojtekM
wojtekM

Reputation: 1

EDIT: I've changed ssh server on windows host from OpenSSH to FreeSSHd and the code worked !

Upvotes: 0

Related Questions