Posted on 02-10-2021 03:31 PM
Hello fellow Jamf Admins,
I'm trying to GET a specific extension attribute and only output the specific result using the following script:
curl -sku $jssUser:$jssPass -H "accept: text/xml" xml=$(https://$orgName.jamfcloud.com/JSSResource/computers/id/$jamfID/subset/extension_attributes)
deviceType=$(echo $xml | xpath "//*[id=$deviceTypeEAID]/value/text()")
This command works perfectly when running it in Catalina and below, but for some reason when I run it in Big Sur I get the following error:
Script result: Usage:
/usr/bin/xpath5.28 [options] -e query [-e query...] [filename...]
If no filenames are given, supply XML on STDIN. You must provide at
least one query. Each supplementary query is done in order, the
previous query giving the context of the next one.
Options:
-q quiet, only output the resulting PATH.
-s suffix, use suffix instead of linefeed.
-p postfix, use prefix instead of nothing.
-n Don't use an external DTD.
I'm pretty junior when it comes to scripting, and I'm not sure what the error is referring to or why it only works in older OS X versions. . Any chance someone can walk me through this? Please and Thank you!
Solved! Go to Solution.
Posted on 02-10-2021 06:13 PM
@jordan.maramag Take a look at this post which shows how to deal with the xpath changes in Big Sur: https://www.jamf.com/jamf-nation/discussions/37011/request-for-a-renaming-script#responseChild210111
Posted on 02-10-2021 06:13 PM
@jordan.maramag Take a look at this post which shows how to deal with the xpath changes in Big Sur: https://www.jamf.com/jamf-nation/discussions/37011/request-for-a-renaming-script#responseChild210111
Posted on 02-12-2021 02:12 PM
Thanks @sdagley, I was able to resolve the issue after reading the article!
Posted on 02-12-2021 03:08 PM
https://scriptingosx.com/2020/10/dealing-with-xpath-changes-in-big-sur/
xpath() {
# the xpath tool changes in Big Sur
if [[ $(sw_vers -buildVersion) > "20A" ]]; then
/usr/bin/xpath -e "$@"
else
/usr/bin/xpath "$@"
fi
}