Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 619
  • Last Modified:

Using applescript to run "softwareupdate -ia" and the reboot.. anyone? :D

Hi.

Does anyone have a applescript that wil run softwareupdate -ia and the reboot the mac?


0
ErikVest
Asked:
ErikVest
  • 3
  • 2
1 Solution
 
pgnatyukCommented:
Seems like this article contains the full answer:
Apple Software Update options
http://managingosx.wordpress.com/2009/10/12/apple-software-update-options/
0
 
ErikVestAuthor Commented:
Hi.

Well, it's embarrassing to write this but right after i was finish writing this question i found out the following command: softwareupdate -i -a;reboot. That solved it. But the page was good so i give yoy credit for that.


Best regards
 

 
0
 
ErikVestAuthor Commented:
Se the comment above.
0
 
pgnatyukCommented:
yes. But it's bash. I think you need 'sudo'.
I thought you are looking for Applescript. I didn't want to make a wrapper for these two commands on my Mac now, it was not a good time to reset my computer, so I posted the link. :)
You are welcome.
0
 
ErikVestAuthor Commented:
he he.. well it has to do with what i'm actually thinking about and what i manage to write down.. those two things is sometime not the same.. :D

But for further records i can post the applescript here:

tell application "Remote Desktop"
      set theScript to "softwareupdate -i -a; reboot" --build the command for
the Unix task
      set theTask to make new send unix command task with properties {showing
output:true, user:"root", script:theScript} --build the task

      set theClients to the selection
      if (length of theClients) = 0 then --no sense in whining, and with the
way Apple Remote Desktop works, I'm not sure this condition is possible,
so an empty selection fails silently
      else if (length of theClients) = 1 then
            try
                  display dialog "By default, ARD always selects the topmost computer in
a list. If this is the computer you want to upgrade, click the
\"Okay\" button"
                  --This is a warning I put in, because ARD *always* selects the first
client in a computer list, so while that avoids
                  --a problem with an empty selection, it can create a problem if you
don't notice that the wrong computer is selected
                  --i only ask this if a single computer is selected

                  set theTaskResult to execute theTask on theClients --run the task, save
the results

            end try
      else if (length of theClients) > 1 then
            set theTaskResult to execute theTask on theClients --run the task, save
the results
            --I use an else if, because I don't want any default that would run the
task outside of the specific desired situation
      end if
end tell

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now