-- Script by James Angus 31 Dec 2007 global current_location global script_name global error_issued set script_name to "Auto Mount Work Drives Script" set error_issued to 0 tell application "System Events" tell network preferences get properties set current_location to the name of current location end tell end tell if current_location is "Work" then tell application "Finder" my mount_drive("smb://stewie/www", "www", "192.168.1.8") my mount_drive("smb://leela/ImageLibrary", "ImageLibrary", "192.168.1.7") my mount_drive("smb://leela/Musicadium", "Musicadium", "192.168.1.7") my mount_drive("smb://leela/Websites", "Websites", "192.168.1.7") my mount_drive("smb://leela/CompanyProject", "CompanyProject", "192.168.1.7") end tell end if set error_issued to 0 -- ************** SUB ROUTINES USED BY THIS SCRIPT: ************* on growl_notification(the_title, the_description) tell application "GrowlHelperApp" -- Make a list of all the notification types -- that this script will ever send: --set the allNotificationsList to {"Drive Mounted"} -- Make a list of the notifications -- that will be enabled by default. -- Those not enabled by default can be enabled later -- in the 'Applications' tab of the growl prefpane. --set the enabledNotificationsList to {"Drive Mounted"} -- Register our script with growl. -- You can optionally (as here) set a default icon -- for this script's notifications. --register as application script_name all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Script Editor" -- Send a Notification... notify with name "Drive Mounted" title the_title description the_description application name script_name end tell end growl_notification on mount_drive(the_volume, the_name, the_ip) set ping_result to "none" if the_name is not in (do shell script "ls /Volumes") then try set ping_result to do shell script "ping -c 1 " & the_ip on error error_message number error_number if error_number is 68 then if error_issued is 0 then growl_notification("Ping Failed", "The volume '" & the_volume & "' could not be found") set error_issued to 1 end if return else my growl_notification("Error " & error_number, error_message) return end if end try try mount volume the_volume my growl_notification(the_name & " available", "The drive '" & the_name & "' was successfully mounted") on error error_message number error_number my growl_notification("Error " & error_number, error_message) end try end if end mount_drive