constantly check if the virtualbox is started or still booting up from a script
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.
Related videos on Youtube
![Mian Asbat Ahmad](https://i.stack.imgur.com/3AbIP.jpg?s=256&g=1)
Mian Asbat Ahmad
PhD Computer Science from University of York, UK Currently I am working as Senior Research Associate DevOps in Department of Medical Physics and Biomedical Engineering, University College London. Prior to that I was Bioinformatician and Systems Administrator in Royal Brompton and Harefield Trust NHS Hospital (October 2016 to October 2018) Research Associate in Machine Learning and Data Mining in Imperial College London (2015-2016)
Updated on September 18, 2022Comments
-
Mian Asbat Ahmad almost 2 years
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
-
Mian Asbat Ahmad about 11 yearsActually 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.
-
-
Mian Asbat Ahmad about 11 yearsYes 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.