Extension Attribute Script Returns Wrong Result to Casper

mikeharris
New Contributor

Sorry if this is a duplicate question, but I did try searching first.

I am trying to add an extension attribute to determine if a set of Xerox Printer drivers are installed so I can use it as a scope for a policy.

I wrote a script based off of the one in the knowledge base article (See attached image).

When I run this script via ssh on a machine it returns the correct result (In this case "Yes" because there are printer drivers installed).

The same script run on the same computer as part of Casper's inventory update returns a result of "No".

Not sure what is going on that would cause this.82a0728de2cb433aa389fe771a98beeb

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

I have a feeling the wildcard use in the test is messing things up. It doesn't work for me either if I use it and replace the last part of the path test with something that exists on my Mac. I don't think you can use it that way, but maybe someone knows of a way to make it work as is.

I would recommend doing it this way for now-

#!/bin/bash

if [[ $(ls "/Library/Printers/PPDs/Contents/Resources/" | grep "8900X") ]]; then
    echo "Yes"
else
    echo "No"
fi

View solution in original post

4 REPLIES 4

mm2270
Legendary Contributor III

I have a feeling the wildcard use in the test is messing things up. It doesn't work for me either if I use it and replace the last part of the path test with something that exists on my Mac. I don't think you can use it that way, but maybe someone knows of a way to make it work as is.

I would recommend doing it this way for now-

#!/bin/bash

if [[ $(ls "/Library/Printers/PPDs/Contents/Resources/" | grep "8900X") ]]; then
    echo "Yes"
else
    echo "No"
fi

hcodfrie
Contributor

#!/bin/bash

# Check /Library/Printers/Xerox/PDEs/XeroxFeatures.plugin for the CFBundleShortVersionString installed_driver=$(defaults read "/Library/Printers/Xerox/PDEs/XeroxFeatures.plugin/Contents/Info" CFBundleShortVersionString) echo "<result>$installed_driver</result>"

pblake
Contributor III

@mikeharris I agree with @mm2270, I don't believe you can use a wildcard when putting something in quotes.

mikeharris
New Contributor

MM2270's response was the fix.

Thanks a ton!