Help with Automator: Software Update from Terminal

Discussion in 'macOS' started by dops7107, Jun 18, 2010.

  1. dops7107 macrumors 6502a

    dops7107

    Joined:
    Mar 19, 2005
    Location:
    Perth, Oztrailya
    #1
    Hello Mac fans,

    Minor niggle here. I am trying to run Software Update from the command line so that I can automate it to run in the middle of the night, to use my of-peak download quota.

    I have set up an Automator task to do this (attached). The problem is, it doesn't really work properly. The situation is this:

    1) if I enter "softwareupdate -l" [this just lists available updates] in the shell script part of the Automator workflow, it works just fine and completes, leaving a log file saying so.

    2) If I enter "softwareupdate -i -a (or -r) [install all (or recommended) updates), when there are updates available the workflow appears to hang after it has downloaded, but not installed, the first update in the list. I know this from looking at Activity Monitor while the workflow is running. It downloads, then all disk/network activity stops. The workflow never completes.

    3) If I enter "softwareupdate -i -a (or -r) [install all (or recommended) updates), when there are no updates available, the workflow completes.

    4) If I execute any of the above softwareupdate commands directly from Terminal myself, they all work and complete properly, installing updates as required.

    So my question is: why does it behave properly when I run it manually from the command prompt, or when there are no updates available as part of the Automator workflow, but not otherwise?

    I have edited the sudoers etc file so that I do not have to enter my password when running "sudo softwareupdate". Are there additional changes I have to make or commands to enter? I just can't figure out why it works when I type it in myself.

    Any help much appreciated.
     

    Attached Files:

  2. Fearless Leader macrumors 68020

    Joined:
    Mar 21, 2006
    Location:
    Hoosiertown
    #2
    I do not know the idiosyncrasies of automator, but do you have a particular attachment or reason to use it?

    launchd (updated version of cron) is how scheduling works on the mac, and software update uses it too. You can actually edit the file it uses to determine update times to when you want it too, but that leaves a bit to be desired.

    I recommend turning off its self update, it can actually download updates in the background which might lead to a surprise multi hundred meg download, and writing your own schedule file.

    http://www.apple-laptop-store.com/TB/?P=5951 That should tell you more than enough on this subject.

    Peace.
     
  3. dops7107 thread starter macrumors 6502a

    dops7107

    Joined:
    Mar 19, 2005
    Location:
    Perth, Oztrailya
    #3
    Thanks Fearless, I'll give that a try. It does look a whole lot simpler. One of the things I quite liked about doing it with Automator is that I could get it to leave a log file telling me what it has updated (in theory at least) - and I could do that without knowing much scripting/programming.
     
  4. Fearless Leader macrumors 68020

    Joined:
    Mar 21, 2006
    Location:
    Hoosiertown
    #4
    for a log
    Code:
     softwareupdate -i -r &> ~/Desktop/log\ `date +%Y-%m-%d__%H-%M`.txt
    that command should take care of you, you can change the "~/Desktop/" to where ever it's more convenient.

    I am unfortunately(?) up to date and can't test it.. In working out one detail of this, I think I figured out why Automator is failing you. I'll do my best to go easy. In the terminal there are multiple layers or types of inputs and outputs. Automator only gleams one of 3 that are being used. When it has nothing to report, it freaks out. The softwareupdate command seems to be using at least 2, maybe 3 of those layers. The actual listing of updates is one type that automator doesn't touch, and the starting text is one that it does. That command I crafted gleams everything it does.

    Peace.
     
  5. dops7107 thread starter macrumors 6502a

    dops7107

    Joined:
    Mar 19, 2005
    Location:
    Perth, Oztrailya
    #5
    Top banana, that will do the job nicely - thanks! Yes, the inability to test these things is annoying, I too am up-to-date. Sometimes I wonder if in fact I should hold back on updates, it's not like I need every last 9.x version of iTunes.

    Peace indeed.
     

Share This Page