Page 1 of 1

Using VBoxManage's guestcontrol To Launch A Program In Linux

Posted: 10. Dec 2012, 09:31
by SpaceRook
Hi,
I am using an Ubuntu 12.04 guest in a Windows 7 host. I would like to launch Ubuntu's Firefox using a command in Windows. I discovered the vboxmanage guestcontrol function and it sounds like it does exactly what I want. The problem is that I can't get it to work. Here is the command and output that I type at the DOS prompt:

Code: Select all

C:\VirtualBox>VBoxManage.exe guestcontrol MyVirtualMachineUbuntu exec --image /usr/bin/firefox --username bob --password password --wait-stdout --verbose
Waiting for guest to start process ...
Waiting for process to exit ...
Exit code=1 (Status=500 [successfully terminated])
I have my Ubuntu machine running. Nothing visibly happens, except the VBoxService process spikes up in the "top" command, so something is happening. When I replace the Firefox command with /bin/ls, the command works:

Code: Select all

C:\VirtualBox>VBoxManage.exe guestcontrol MyVirtualMachineUbuntu exec --image /bin/ls --username bob --password password --wait-stdout --verbose
Waiting for guest to start process ...
Waiting for process to exit ...
bin
boot
cdrom
dev
etc
......
So it seems like I can get stdout from simple commands to display, but I don't know how to launch programs/scripts. Is anyone able to launch a program like Firefox in an Ubuntu guest via a command in the Host? If you have any idea about general guest/host communication best practices, I'd also be interested in that.

Thanks.

Re: Using VBoxManage's guestcontrol To Launch A Program In L

Posted: 16. Dec 2012, 18:06
by BinarySplit
The problem is most likely that guestcontrol executes what you give it in its own console, rather than within your graphical desktop environment.

I was able to get Firefox to run successfully by running the following command. Note that using /bin/sh with the -c argument is helpful in running more complex commands. You'll also have to replace the user/pass/homedir with your own.

Code: Select all

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe guestcontrol "Ubuntu 12.10" exec --image /bin/sh --username AzureDiamond --password hunter2 --wait-stdout -- -c "env XAUTHORITY=/home/AzureDiamond/.Xauthority DISPLAY=':0' /usr/bin/firefox"
See here for more info on launching GUI applications from a non-GUI terminal - also useful if you're using SSH to access your VM remotely.