#!/bin/sh usage() { cat 1>&2 < stops the given VM, restores the current snapshot and restarts it again OPTIONS -w attach host's webcam to VM -a if no is given, try to automatically guess it (using the currently running one, if this is unambiguous) EOL if [ "x${1}" != "x" ]; then cat 1>&2 <&2 fi } webcam=no auto_vm=no while getopts "h?wa" opt; do case $opt in w) webcam=yes ;; a) auto_vm=yes ;; h|\?) usage exit 0 ;; :) usage exit 0 ;; esac done shift $((OPTIND-1)) vm=$1 if test "x${auto_vm}" = "xyes" && test "x${vm}" = "x"; then vm=$(vboxmanage list runningvms | grep -c .) if [ "${vm}" -eq 1 ]; then vboxmanage list runningvms vm=$(vboxmanage list runningvms | awk '{print $2}' | tail -1) else cat 1>&2 <