xmllint parser error

thlemaire
New Contributor

Hello all,

i am seeking out any advice for a script that i have that through an api call reads a value inside an extension attribute populated in a computers inventory then returns this value in a variable.

i am using curl for the API call that is working fine but every time i add a pipe for xmllint i get parser errors that i am unable to eliminate.

This is the command that i send.

/usr/bin/curl -sk -H "Authorization: Basic echo -n $SUPERUSER:$SUPERPASSWORD | base64" -H "Accept: text/xml" https://$JssUrl/JSSResource/computers/udid/$Udid/subset/extension_attributes -X GET | xmllint -xpath "//extension_attributes/extension_attribute[contains(name, 'LAPS')]/value/text()" -

i think the issue relies on how the xmllint -path line is formated.

has anyone encountered this type of issue ?

Thanks in advance for any help provided

3 REPLIES 3

dan-snelson
Valued Contributor II

@thlemaire After searching some working scripts for xmllint, the following variables are working for me, using a shebang of: #!/bin/bash

policyNames=$( curl -H "Accept: text/xml" -sfku "${apiUser}:${apiPassword}" "${apiURL}/JSSResource/policies" | xmllint --format - | awk -F'>|<' '/<name>/{print $3}')

policyName=$( xmllint --xpath "/policy/general/name/text()" ${updatesDirectory}/policy-${policyID}.xml )

--
Dan

thlemaire
New Contributor

@dan-snelson Many thanks for your help.

i managed to succeded with this command

/usr/bin/curl -ksu "$SUPERUSER:$SUPERPASSWORD" -H "Accept: text/xml" $JSSUrl/JSSResource/computers/udid/$udid | xmllint --xpath "//extension_attributes/extension_attribute[contains(name, 'LAPS')]/value/text()" -

i still have to review the end of the script as i am detecting that i will have other problems there. for some reason the api call for computers/udid was updated. maybe before it was possible to aim directly subset/extention_attributes but after checking the classic api call in jamf 10.26 this seems to be not an option anymore. and the new API interface based on a token based authentication seems not to provide this option to GET or PUT based on computer udid.

dan-snelson
Valued Contributor II

Glad you got it working, @thlemaire.

On the off chance a snippet or two from the following proves helpful with modifying EAs via the API:
Your Internal Beta Test Program: Opt-in / Opt-out via Self Service


--
Dan