A Simple Script to Start a Linux Virtual Box using Automator

July 1, 2010  |  Howto, Script, Virtual Box

Here is a simple script you can use to create an icon to launch a Virtual Box VM in headless mode using an Automator application. Simply start automator drop and paste this code into a AppleScript window.


on run {input, parameters}

do shell script "vboxmanage startvm [VM NAME] --type headless "

do shell script "sleep 60"

tell application "Terminal"
if (count of windows) is 0 then
do script "ssh -l root root@[VM IP ADDRESS]"
else
do script "ssh -l root root@[VM IP ADDRESS]" in window 1
end if
activate
end tell

return input
end run

This script is designed for a VM running Debian and will launch your VM in headless mode wait, 60 seconds and then launch and SSH session within terminal window.

If you launch this whilst the VM is already running you’ll get an error. You could get round this by putting a simple if statement to check and see if the VM is running, and if so simply launch the terminal window and not attempt to relaunch the VM

You could even save the workflow as an application and drop it on your dock with a cool icon.


Leave a Reply

Comment moderation is enabled, no need to resubmit any comments posted.