I am writing a shell script to start a virtualbox (ubuntu). After the command I want to put a for loop to keep checking the status of virtualbox and the script comes out of the loop only after the ubuntu is fully started. Something like

vboxmanage starvm Ubuntu

for (i= 0; i < 100; i++)
continue if (vbox is not on)

exit when vbox is fully on and execute the next command

  • Actually I want to know if there is any command from which we can check the status of the machine because after Ubuntu is booted, I want ssh connection to it.
    – drmaa
    Jun 13, 2013 at 11:03

2 Answers 2


We can use VBoxManage to query the state of a Virtual Machine. The following command will list all running virtual machines on your system:

VBoxManage list runningvms

The output will show you the following information which you can then further parse in your script:

"name_of_machine" <UUID>

This will of course not tell you whether the guest OS had booted properly, or is ready to use. For such informations you may need to run a script on the guest starting after boot to send it's running state to the host.

  • Yes you are right for that purpose we need to have a script inside the guest OS. They also suggest the same thing forums.virtualbox.org/viewtopic.php?f=1&t=50241. Since my next command in the script is to ssh the guest OS after boot therefore I will check if I add it in the loop and continue untill connection is established to the guest os.
    – drmaa
    Jun 13, 2013 at 11:55

I know its a bit late to answer that question. but it might help others. you can run the following command to get the state of your Virtual machine

VBoxManage list vms -l | grep -e Name: -e State

it will tell you all of the virtual machines along with their status. run this command in your loop, check each machine status.

if( stopped || paused ) 
VBoxManage startvm VMNAME           //here VMNAME is variable containing name of your vm
//do nothing

do it for all your vms. i hope it helps

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .