VirtualBox

Ticket #17319 (new defect)

Opened 5 years ago

Last modified 5 years ago

"VBoxManage guestcontroll run" stdin/out redirection not working

Reported by: shangouet Owned by:
Component: guest control Version: VirtualBox 5.1.30
Keywords: guestcontroll run stdin stdout Cc:
Guest type: Windows Host type: Linux

Description

I'm trying to run a python script inside a Windows 7-64bit virtual machine, redirecting stdin and stdout from/to Ubuntu 17.10 host.

GuestAdditions and python have been installed on the VM. I placed the python script on a shared directory.

The following commands never exits and does not echo anything until I pressed CTRL+C :

echo -1 | VBoxManage --nologo guestcontrol "w764 Clone" run --username Hector --password hectorH --exe "C:\Python27\python.exe" --wait-stdout -- E:\test.py

Here is the script "test.py":

print("Hello")
while True:
    s = raw_input()
    a = int(s)
    print(a)
    if a < 0:
        break

I first tried to run it inside a windows terminal on the VM, and this works:

c:\> c:\python27\python.exe E:\test.py
Hello
-1
-1

To make sure the login parameters are ok, I run iexplore with success:

VBoxManage --nologo guestcontrol "w764 Clone" run username Hector --password hectorH --exe "C:\Program Files\Internet Explorer\iexplore.exe"

Change History

comment:1 Changed 5 years ago by shangouet

Edit : the first command given in the description should use db-quotes to pass arguments:

echo -1 | VBoxManage --nologo guestcontrol "w764 Clone" run --username Hector --password hectorH --exe "C:\Python27\python.exe" --wait-stdout -- "E:\test.py"

Anyway, the result is the same, but the first version should have raise an error : it seems the problem comes from argument passing. I'll investigate this.

comment:2 Changed 5 years ago by shangouet

Ok, first problem : I found in a comment of https://www.virtualbox.org/ticket/14506 that the first arg passed must be argv[0].

This makes my command line like this:

echo -1 | VBoxManage guestcontrol (...) --exe "C:\Python27\python.exe"
 --wait-stdout -- "python.exe" "E:\test.py"

This time a script with just a print command works, but as soon as I try to read from stdin, it remains stuck.

Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use