Re: AppleScript-Users Digest, Vol 5, Issue 126
Re: AppleScript-Users Digest, Vol 5, Issue 126
- Subject: Re: AppleScript-Users Digest, Vol 5, Issue 126
- From: "Stockly, Ed" <email@hidden>
- Date: Thu, 21 Feb 2008 17:38:58 -0800
- Thread-topic: AppleScript-Users Digest, Vol 5, Issue 126
>Mark> What exactly are you trying to prevent/detect? If people can get to your
servers, open them up, and swap disk drives around without being noticed, i
think you have some security problems that no script is going to address...
>>> I agree. Instead of writing a script, put your servers and RAIDS in a
locked room.
Even better, put all your computers in a locked room and don't let those
pesky users anywhere near them. That would make the administrator's job so
easy.
>>>>>I need to write a script to run on an xserve, Tiger, to send an email, say
to the sysadmin if the inventory of any of the internal hard drives have been
removed or changed. Can someone help, I am just beginning to learn scripting.
I've been looking for one that exists already but haven't found one yet.
Ignoring whatever security issues you may have, I think we may need more
information on what you're trying to accomplish.
It is possible to write an appleScript that stores a file (or a property)
that contains a unique identifier for each drive on your system.
Something like this:
property existingDriveSerialNumbers : ""
tell application "System Profiler"
make new document
end tell
with timeout of 600 seconds -- grr
tell application "System Profiler"
set myInfo to profile of document 1
quit
end tell
end timeout
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "spata_device_serial:"
-- look at your system profiler to see what string(s) to use here
set myInfo to every text item of myInfo
set NewDeviceSerialNumbers to {}
set foundDeviceSerialNumbers to {}
repeat with x from 2 to (the count of myInfo)
set thisSN to line 1 of item x of myInfo
set the end of foundDeviceSerialNumbers to thisSN
if thisSN is not in existingDriveSerialNumbers then
set the end of NewDeviceSerialNumbers to thisSN
end if
end repeat
set missingDriveSerialNumbers to {}
repeat with oldSN in existingDriveSerialNumbers
if oldSN is not in NewDeviceSerialNumbers then
set the end of missingDriveSerialNumbers to oldSN
end if
end repeat
set AppleScript's text item delimiters to ", "
set rightNow to {time string of (current date), date string of (current
date)} as string
set AppleScript's text item delimiters to return
set dearAdmin to {rightNow, "", "Hey, Administrator,", ""}
set the end of dearAdmin to {"Due to our lax security someone installed
drives with these serial numbers on our server:,"}
set the end of dearAdmin to NewDeviceSerialNumbers as string
set the end of dearAdmin to {"", "and someone removed these drives:"}
set the end of dearAdmin to missingDriveSerialNumbers
set the end of dearAdmin to {"Sincerely,","", "Your Trusty AppleScripter"}
set dearAdmin to dearAdmin as string
set AppleScript's text item delimiters to oldDelims
You could then trigger the script to run at a specific interval or whenever
the mac is restarted and then script Mail or entourage to send an email.
BUT, be careful scripting system profiler it's waay lame.
It sure would be sweet if we could do something like
Tell application "system profiler"
Get my devices profile
end
Or if the commands in the dictionary would just work without freezing and
crashing.
You may be able to find better ways to get this info, but this could get you
started.
ES
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden