Wait until the guest execution service is ready

Discussions about using Linux guests in VirtualBox.
Post Reply
OracleVirtual
Posts: 4
Joined: 9. Mar 2015, 18:15

Wait until the guest execution service is ready

Post by OracleVirtual »

Hi all,

I want to execute a command from Windows host to Linux guest by VBoxManage after virtual machine is started.

I do this:

Code: Select all

VBoxManage startvm vmachine
VBoxManage guestcontrol vmachine execute /bin/echo "hello" --username user --password user
When the sencond line is executed I get the next error:

"The guest execution service is not ready (yet)"

How can I wait until the guest execution service is ready?
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Wait until the guest execution service is ready

Post by socratis »

Wait for a couple of minutes until the guest is up and running? I don't know... It seems logical???

Now, if you want to check in your script, you can:
  • Check for the availability of the guest in the network, either directly or by looking at a shared file in a known network location, or
  • Loop until you get no error, or
  • Time with a clock how long it takes your guest to start and put it in a wait timer.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
genEric
Posts: 10
Joined: 9. Mar 2015, 02:00
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Arch, Fedora 21, Win7
Location: Sweden

Re: Wait until the guest execution service is ready

Post by genEric »

You could try to put the first command in an if statement, or try: wait

Code: Select all

VBoxManage startvm vmachine
wait
VBoxManage ...
[genEric@...] $
OracleVirtual
Posts: 4
Joined: 9. Mar 2015, 18:15

Re: Wait until the guest execution service is ready

Post by OracleVirtual »

socratis wrote: [*]Loop until you get no error, or
How can I perform this? I use a windows batch file.
OracleVirtual
Posts: 4
Joined: 9. Mar 2015, 18:15

Re: Wait until the guest execution service is ready

Post by OracleVirtual »

I do this:

Code: Select all

:CheckVBox
VBoxManage guestcontrol vm execute /bin/echo "CheckVBox" --username user --password user --wait-stdout
IF ERRORLEVEL 1 (
  sleep 15
  GOTO CheckVBox
)
Regards.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Wait until the guest execution service is ready

Post by scottgus1 »

ERRORLEVEL may one day come up with an error other than 1, so you'd probably want to test:
IF NOT %ERRORLEVEL%==0
Otherwise, a good solution! I have made the host script set a guestproperty to a certain value, and a guest script that runs the guest version of Vboxmanage (VboxControl.exe) to reset the guestproperty. The host script waits until the guestproperty is reset, and proceeds. The guest script is in some startup folder or group policy script, depending on what I needed.
Post Reply