/build/static/layout/Breadcrumb_cap_w.png

Bash Scripting Help In Custom Inventory Rule

I'm running this script in my ShellCommandTextReturn CIR.  Simply want to check to see if our Mac users have this line in their Chrome plist file.  If they don't, I'll base a script off of this to add it via smart label.

I can run this on my machine as root and myself with success but once made into a Custom Inventory Rule, regardless of the user having Chrome or not, the value will always be "No Chrome File Present"

This command does contain sub-commands so is KACE unable to run sub-commands in these CIRs? I'm running other simpler ones such as these with no problems:

ShellCommandTextReturn(diskutil info /dev/disk0 | egrep -i '(media name|total size|solid state)')
ShellCommandTextReturn(fdesetup status)

Here is my script:

if [ -f "/Users/$(who | grep console | awk '{print $1}')/Library/Preferences/com.google.Chrome.plist" ]; then if defaults read /Users/$(who | grep console | awk '{print $1}')/Library/Preferences/com.google.Chrome | grep AuthServerWhitelist 1>/dev/null; then echo ChromeKerberosSet=Yes; else echo ChromeKerberosSet=NO; fi ; else echo "No Chrome File Present"; fi

0 Comments   [ + ] Show comments

Answers (1)

Answer Summary:
Posted by: tylerpenn 9 years ago
Senior White Belt
2
I figured it out.

Apparently the K1000 didn't think I was smart enough to write my own BASH script so it added some extra quotes in certain places.  I checked the KAgent.log after an inventory of my machine and saw the original script then the KACE-ized version right after (the one that was actually getting executed) and removed some of my quotes to accommodate them getting added later.

So in short, if you're attempting to do some more advanced BASH scripting for Linux/Unix systems in your Custom Inventory Rules, use fewer quotes

Comments:
  • yep. another way to look at it is to use backticks. Also, watch out for smart quotes. they will mess things up. - MacDude 9 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ