I have this script that i want to run only if it is connect to our net work. I have it check the ip at the start of the script and i want it to stop if the ip dose not match what i tell it to. I can not get it to work, just seems to skip over that part.
get IPv4 address of (system info)
set myIP to result
if myIP does not contain 151.145 then stop
tell application "System Events" to get name of current user
set iUser to result
set idev to ":"
set iVolume to "EMPLOYEE_BACKUP"
set ides to iVolume & idev & iUser
tell application "System Events" to set EntourageRunning to (application process "Microsoft Entourage" exists)
if (EntourageRunning) then
display dialog "Entourage is running. Entourage must be closed to backup database. Shut down Entourage Now?" buttons {"Cancel", "Quit Now"} default button 2 with icon stop giving up after 40
if button returned of the result is "Quit Now" then
tell application "Microsoft Entourage" to quit
tell application "System Events"
repeat while (application process "Microsoft Entourage" exists)
delay 0.5
end repeat
end tell
beep
else
-- Do not shutdown Entourage or waited longer than 10 seconds
-- abort Script:
error number -128
end if
end if
-- Entourage is not running at this point.
if (list disks) does not contain iVolume then
display dialog "Enter Network Password" default answer "" with hidden answer
set iPass to the text returned of the result
set iServer to "afp://myserver/EMPLOYEE_BACKUP"
do shell script "mkdir //Volumes/mntpnt; /sbin/mount -t afp afp://`whoami`" & ":" & iPass & "@myserver.na.company.com/EMPLOYEE_BACKUP //Volumes/mntpnt"
delay 5
end if
with timeout of 500000 seconds
tell application "Finder"
duplicate file "Documents:Microsoft User Data:Office 2004 Identities:Main Identity:Database" of home to folder ides with replacing
end tell
display dialog "Your Entourage database has been backed up. You may now safely reopen entourage." buttons {"OK"} giving up after 20
end timeout
quit