AppleScript Inside of Shell Script to display Software Update Message...

russeller
Contributor III

I know there has been discussions about displaying messages to end users for reminders, etc. Growl has been mentioned a lot, but I decided it would be an awesome idea to write a cool AppleScript and wrap it in a shell script and deploy it via a scoped JSS policy to remind teacher in my school district to run updates. Using AppleScript allows me to put a the Self Service icon on the message window, and use buttons to launch Self Service, etc. It could probably use some tweaking and any suggestions are welcome (even to tell me that it's a lame idea, and you have a better solution).

Here it is:

#!/bin/sh

exec osascript <<EOF

tell application "Finder"

activate

set question to display dialog "Your computer needs to install Apple Software Updates. It is critical these updates run. Click the 'Open Self Service' button and the updates will immediately start running on your Computer, it could take up to an hour for the updates to complete. DO NOT Interrupt the updates or your system could become unusable. PLEASE plug your computer into the power outlet before starting." buttons {"Remind Me Later", "Open Self Service"} default button 2 with icon alias "Macintosh HD:Applications:Self Service.app:Contents:Resources:Self Service.icns"

set answer to button returned of question

if answer is equal to "Open Self Service" then

tell application "Safari" to make new document with properties {URL:"selfservice://dist-mac-tech-3.capousd.org/product=433"}

else if answer is equal to "Remind Me Later" then

set question to display dialog ¬

"You will be reminded daily until your Apple Software Updates have been completed." buttons {"OK", "Fine, Open Self Service"} default button 2 with icon alias "Macintosh HD:Applications:Self Service.app:Contents:Resources:Self Service.icns"

if answer is equal to "Fine, Open Self Service" then

tell application "Safari" to make new document with properties {URL:"selfservice://dist-mac-tech-3.capousd.org/product=433"}

else if answer is equal to "OK" then

error number -128

end if

end if

end tell

This script does a weird thing (only in 10.4.11) where it launches Safari before displaying the dialog, but doesn't go to the URL, just launches Safari, then displays the dialog.

Steven Russell
Capistrano Unified School District
Technology Support Specialist
(949) 234-5522
ssrussell at capousd.org

CAPISTRANO UNIFIED SCHOOL DISTRICT DISCLAIMER:

This communication and any documents, files, or previous e-mail messages attached to it constitute an electronic communication within the scope of the Electronic Communication Privacy Act, 18 USCA 2510. This communication may contain non-public, confidential, or legally privileged information intended for the sole use of the designated recipients(s). The unlawful interception, use, or disclosure of such information is strictly prohibited under 18 USCA 2511 and applicable laws.

0 REPLIES 0