A script to check software updates on LAN machines

Oct 13, '04 09:08:00AM

Contributed by: Leo71

If you have a remote server (like an XServe) or other Macs on the LAN, and you need to know when you need to update the system, maybe the following AppleScript may help you. It checks to see if there is a software update from Apple and send you an email.

Read the rest of the hint for the script.

[robg adds: If this sort of thing is of interest to you, then this hint, and particularly the associated comments, are probably worth reading, too.]

set subjectmail to "Software Update from Xserve" 
set mailxserve to "youremail@xserve" 
set myname to "My name" 
set mail to "youremail@work" 

--- change xxx.xxx.xxx.xxx to a IP address or webserver
--- you like better i.e. www.apple.com  ---- 
set ping_result to (do shell script "ping -c 1 xxx.xxx.xxx.xxx") 
--- check if network is on ---- 

if "100% packet loss" is in ping_result then 
  quit 
else 
  --- check for update --- 
  try 
    set restlist to do shell script "softwareupdate -l" 
  end try 
  if "Your software is up to date" is not in restlist then 
    --- send an emil if a new update is found --- 
    tell application "Mail" 
      set newMessage to make new outgoing message with ¬
       properties {subject:subjectmail, content:restlist & return & return}
       tell newMessage 
        set visible to false --- true if u wanna see mail sending mail 
        set sender to mailxserve 
        make new to recipient at end of to recipients with ¬
         properties {name:myname, address:mail}       end tell 
      send newMessage 
    end tell 
    ---- You can add more actions here ---- 
  end if 
end if 
You can save this script as an application, and schedule once or more a day with iCal.

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20041007154057172