Skip to main content
Answer

Software Update via CLI and friendly names

  • October 19, 2012
  • 1 reply
  • 17 views

dpertschi
Forum|alt.badge.img+19

I want to create a Self Serve item that will then list the available software updates with the friendly name like you'd get from the GUI, not the ugly output you get from the command line; even though I'll have to call the command line version to grep whats available.

I haven't thought out the delivery logic yet; jamfHelper, shell, Applescript, custom triggers etc.

Whatever the case, is there a way to pull the nice names from the command line?

thanks,
Darrin

Best answer by mm2270

An excerpt from a script I wrote some time back to handle a simlar situation. Basically, export the results of 'softwareupdate -l' to a local file in /tmp, then read it back in and extract the bits you need into a variable. Later you can use that variable text in a jamfHelper display, Applescript window, CocoaDialog, etc.

#!/bin/sh

Date=`date +%m-%d-%Y`
SWUList=`softwareupdate -l > /tmp/SWUList_$Date.txt`
ReadList=$(cat /tmp/SWUList_$Date.txt | awk -F, '/[recommended]$/{ print $1 }')

echo $ReadList

Couple of things to note-
1, I have not used the above in a while. I know it worked OK with 10.6 and 10.7 but it wasn't working with 10.8. I haven't bothered to look into updating it since we aren't really using this process.

2, jamfHelper has a limited # of lines it can display. Anything extra just gets cut off instead of intelligently resizing. So I had to build a line count check in the script and if it exceeded a certain threshold (don't recall how many lines it can display) I made an Applescript window come up instead, since it can handle that more gracefully.

Hope it helps get you started though.

1 reply

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • Answer
  • October 19, 2012

An excerpt from a script I wrote some time back to handle a simlar situation. Basically, export the results of 'softwareupdate -l' to a local file in /tmp, then read it back in and extract the bits you need into a variable. Later you can use that variable text in a jamfHelper display, Applescript window, CocoaDialog, etc.

#!/bin/sh

Date=`date +%m-%d-%Y`
SWUList=`softwareupdate -l > /tmp/SWUList_$Date.txt`
ReadList=$(cat /tmp/SWUList_$Date.txt | awk -F, '/[recommended]$/{ print $1 }')

echo $ReadList

Couple of things to note-
1, I have not used the above in a while. I know it worked OK with 10.6 and 10.7 but it wasn't working with 10.8. I haven't bothered to look into updating it since we aren't really using this process.

2, jamfHelper has a limited # of lines it can display. Anything extra just gets cut off instead of intelligently resizing. So I had to build a line count check in the script and if it exceeded a certain threshold (don't recall how many lines it can display) I made an Applescript window come up instead, since it can handle that more gracefully.

Hope it helps get you started though.