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,837 times
0
-
2possible duplicate of How to start a Virtualbox machine via command line (without GUI)? or 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? – 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,429
- 1
- 12
- 19