WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Virtualbox Additions Guestcontrol  (Read 11833 times)

Offline Duncan

  • Newbie
  • *
  • Posts: 2
Virtualbox Additions Guestcontrol
« on: March 13, 2012, 08:41:52 AM »
Hi, has anyone got the guest execution VBoxManage API to work with the virtualbox additions module?

I've installed the additions module and got shared folders to work fine but whenever I fire up a VboxManage command such as:

VBoxManage guestcontrol <machineid> exec --image /bin/ls --username tc --password <password>

I get:

VBoxManage.exe: error: The guest execution service is not ready (yet).

even though the machine itself obviously is ready.

Thanks!

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: Virtualbox Additions Guestcontrol
« Reply #1 on: March 13, 2012, 03:14:27 PM »
I haven't had a need for this feature so far, therefore I had to do a bit of RTFM followed by some "poking around". But in the end its pretty simple: Apart from having the virtualbox-ose-additions.tcz extension installed one also needs to ensure that the "active component on the inside" is running. I therefore started it via sudo VBoxService, and following this 'VBoxManage guestcontrol' worked for me.

Some further remarks:
  • to be able to "see" the 'stdout' output the '--wait-stdout' option has to be added to the 'VBoxManage guestcontrol' command,
  • to be able to "see" the 'stderr' output the '--wait-stderr' option has to be added to the 'VBoxManage guestcontrol' command; doing this OTOH prevented me to "see" the 'stdout' output and even adding '--wait-stdout' as well did not change the outcome,
  • any arguments for the remote command execution need to be added at the end of the 'VBoxManage guestcontrol' command (preceded by '--').

So all together: if one wants to run 'ls -lRa /home/tc/.local' (in a VM called 'TC4') this could be done like this:
Code: [Select]
C:\>VBoxManage guestcontrol TC4 exec --image /bin/ls --username tc --wait-stdout -- -lRa /home/tc/.local
/home/tc/.local:
total 0
drwxr-sr-x    3 tc       staff           60 Mar 13 22:02 .
drwxr-sr-x    3 tc       staff          120 Mar 13 22:02 ..
drwxr-sr-x    2 tc       staff           40 Mar 13 22:02 bin

/home/tc/.local/bin:
total 0
drwxr-sr-x    2 tc       staff           40 Mar 13 22:02 .
drwxr-sr-x    3 tc       staff           60 Mar 13 22:02 ..

Offline Duncan

  • Newbie
  • *
  • Posts: 2
Re: Virtualbox Additions Guestcontrol
« Reply #2 on: March 14, 2012, 04:36:47 AM »
Maro, that is brilliant! thank you very much!  ;D
« Last Edit: March 14, 2012, 04:45:12 AM by Duncan »