How do I start Virtualbox from the command line and start a Ruby script on the guest and after the script is done close the guest? What could be easiest way to do this?
1 Answer
You can start the VM with VBoxManage:
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm <NameOfVMHere>
After the VM has booted you can run a program if you have guest editions installed:
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" guestcontrol exec --image <path to program> --username <name> [--password <password>] [--wait-exit] [--wait-stdout] [--wait-stderr]
Finally, when the program has finished executing you can close the VM with the command:
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm <vm> savestate
Alternatively, you can shutdown the machine with a command at the end of the Ruby Script
-
But how to start ruby script you say: --image path to program, but I want to start ruby.rb like I do in command line ruby ruby.rb– DakadakaFeb 18, 2013 at 16:20
-
-
Make a script with the command you normally run and then call the script.– DavidFeb 19, 2013 at 16:35
-
It gives an error that 'ruby' is not recognized as an internal or external function, even though the ruby executable is in path. Dec 8, 2015 at 21:41