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:
0 Comments
[ + ] Show comments
Answers (1)
Answer Summary:
Please log in to answer
Posted by:
tylerpenn
10 years ago
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 10 years ago