0

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 1

0

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

4
  • 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
    – Dakadaka
    Feb 18, 2013 at 16:20
  • I mean as guest to start in the guest ruby or php
    – Dakadaka
    Feb 18, 2013 at 16:29
  • Make a script with the command you normally run and then call the script.
    – David
    Feb 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

You must log in to answer this question.

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