Posted on 04-04-2016 01:04 PM
I'm trying to script a program to open and close during inventory update quickly as well as be hidden. I can do this as a launch agent, but I'd really like this info to update during the inventory collections. Its the smart utility program which has an extension attribute script already but it wont update its info unless the user opens the smart utility app from time to time.
So far Ive succeeded in getting the app to open hidden and close but adding those commands to the extension attribute script do not perform the desired action. Any help would be greatly appreciated.
Below are the 2 parts:
#!/bin/bash
open -jg -a /Applications/SMART Utility.app
pkill SMART Utility.app
installed=0;
for username in $(dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'); do
if [ -e /Users/"${username}"/Library/Application Support/SMART Utility/DrivesList.plist ]; then
installed=1;
checkTime=`defaults read /Users/"${username}"/Library/Application Support/SMART Utility/DrivesList.plist CheckTime`
problemDriveCount=`defaults read /Users/"${username}"/Library/Application Support/SMART Utility/DrivesList.plist SUProblemDrivesCount`
if [ "$problemDriveCount" -gt 0 ]; then
for i in {0..."$problemDriveCount"}; do
driveHealth=`/usr/libexec/PlistBuddy /Users/"${username}"/Library/Application Support/SMART Utility/DrivesList.plist -c "print SUProblemDrives:0:DriveHealth"`
driveNames=`/usr/libexec/PlistBuddy /Users/"${username}"/Library/Application Support/SMART Utility/DrivesList.plist -c "print SUProblemDrives:0:DriveNames"`
driveSN=`/usr/libexec/PlistBuddy /Users/"${username}"/Library/Application Support/SMART Utility/DrivesList.plist -c "print SUProblemDrives:0:DriveSN"`
driveModel=`/usr/libexec/PlistBuddy /Users/"${username}"/Library/Application Support/SMART Utility/DrivesList.plist -c "print SUProblemDrives:0:DriveModel"`
driveSize=`/usr/libexec/PlistBuddy /Users/"${username}"/Library/Application Support/SMART Utility/DrivesList.plist -c "print SUProblemDrives:0:DriveSN"`
# ***NOTE***
# Customize this echo to your desired output format. Maybe you only want the health and names, or maybe you want everything. Do that here.
# This one is an example
echo "<result>${checkTime} ${driveHealth}: '${driveNames}'</result>"
done
else
echo "<result>At ${checkTime}, All drives passed</result>"
fi
fi
done
if [ "$installed" = 0 ]; then
echo "<result>Not Installed</result>"
fi
exit 0
Gabe Shackney
Princeton Public Schools
Solved! Go to Solution.
Posted on 04-04-2016 01:07 PM
Nevermind, it looks like if I add a sleep 1 inbetween the 1st two commands it works.
Fun...
Gabe Shackney
Princeton Public Schools
Posted on 04-04-2016 01:07 PM
Nevermind, it looks like if I add a sleep 1 inbetween the 1st two commands it works.
Fun...
Gabe Shackney
Princeton Public Schools