Skip to main content
Solved

Scripting softwareupdate


lilylily
Forum|alt.badge.img+3

I'm trying to create a workflow for our school in which a computer can be booted, will check for available software updates and apply any necessary, and then check in with our JSS once no more software updates are identified. I'm curious if anyone has a solution for capturing the server response from the softwareupdate command? So far when I run:

#!/bin/bash
su=$(softwareupdate -l)
echo "$su"

The terminal output is:

No new software available.

Server response and then:

Software Update Tool

Finding available software

Output of echo "$su"

With the server response "No new software available." printing first and without regard for the output of the echoed variable. In other words I only ever seem to be able to programmatically capture "Software Update Tool" and "Finding available software". Does anyone have a solution for capturing the server response from the softwareupdate command?

Best answer by cbrewer

Try redirecting stderr to stdout:
currentupdates=$(softwareupdate -l 2>&1)

Also, I'd recommend either using this script directly or taking ideas from it.

Edit - the $su thing won't be a problem.

View original
Did this topic help you find an answer to your question?

2 replies

Forum|alt.badge.img+15
  • Esteemed Contributor
  • 719 replies
  • Answer
  • November 20, 2019

Try redirecting stderr to stdout:
currentupdates=$(softwareupdate -l 2>&1)

Also, I'd recommend either using this script directly or taking ideas from it.

Edit - the $su thing won't be a problem.


lilylily
Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 6 replies
  • November 21, 2019

Thanks @cbrewer! That JSS script should do the trick.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings