Skip to content

Instantly share code, notes, and snippets.

@eberfreitas
Created November 13, 2015 13:47
Show Gist options
  • Save eberfreitas/32aab76b9cd762efccab to your computer and use it in GitHub Desktop.
Save eberfreitas/32aab76b9cd762efccab to your computer and use it in GitHub Desktop.
Easier VBoxManage
#!/bin/bash
VBOXPATH="/cygdrive/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"
case "$1" in
"start" | "startvm")
echo "Starting VM \"$2\"..."
cmd="\"$VBOXPATH\" startvm $2 --type headless"
eval $cmd
;;
"getip" | "get")
echo "Getting IP address for VM \"$2\"..."
cmd="\"$VBOXPATH\" guestproperty get $2 /VirtualBox/GuestInfo/Net/0/V4/IP"
eval $cmd
;;
"poweroff" | "shutdown")
echo "Shutting down VM \"$2\"..."
cmd="\"$VBOXPATH\" controlvm $2 poweroff"
eval $cmd
;;
*)
echo "Unknown command!"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment