I use Virtualbox. Instead of clicking on the button of the name of the virtual machine to run it, I want a shell script that can run a Windows XP virtual machine hosted on Ubuntu machine. Can someone help me please ?
Asked
Active
Viewed 2,726 times
0
-
2possible duplicate of [How to start a Virtualbox machine via command line (without GUI)?](http://askubuntu.com/questions/445284/how-to-start-a-virtualbox-machine-via-command-line-without-gui/449249) or [launch a VM on Ubuntu](http://askubuntu.com/questions/476646/launch-a-vm-on-ubuntu) – TuKsn Jul 22 '14 at 07:55
-
@Tuknutx He asked a shell script, not a command line. He's new. – Jul 22 '14 at 08:20
-
@begueradj you are right but this are the right commands in the two links and to use it in a script read this [How do I create a script file for terminal commands?](http://askubuntu.com/questions/223691/how-do-i-create-a-script-file-for-terminal-commands) – TuKsn Jul 22 '14 at 08:43
1 Answers
0
VBox_StopRestoreStart.sh
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 VMNAME_or_UUID"
exit 1
fi
set -x
VBoxManage controlvm "$1" poweroff #enforce turnoff
VBoxManage snapshot "$1" restorecurrent #retore state
VBoxManage showvminfo "$1" | grep State #display state to ensure
VBoxHeadless -s "$1" #run in headless mode in background
Nymeria
- 1,411
- 1
- 12
- 19