Yes, its possible. Here's the syntax I would use
/usr/bin/curl -H "Accept: application/xml" -sfku "${apiuser}:${apipass}" https://yourjss.com:8443/JSSResource/computers/udid/${uuid} | xpath /computer/general/name[1] | awk -F'>|<' '/name/{print $3}'
BTW, in the JSS, its actually referred to as the UDID, not UUID, but the info you're grabbing is correct for the curl command. Also, here is a slightly more efficient way to get the UUID/UDID.
/usr/sbin/ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformUUID/{print $4}'
I agree with @mm2270][/url][/url, but my solution would work a little different.
#!/bin/sh
########################################################################
# User changable settings...
########################################################################
jssUser='username'
jssPass='password'
jssHost=https://jssurl.com:8443/
########################################################################
# Code below
########################################################################
OSVersion=$(sw_vers -productVersion)
uuid=$( /usr/sbin/system_profiler -xml SPHardwareDataType | /usr/bin/xpath "//array/dict/array/dict/string[preceding-sibling::key='platform_UUID'][1]/text()" 2> /dev/null )
xmlComputerInfo="<?xml version="1.0" encoding="ISO-8859-1" ?>
<computer>
</computer>"
theJSSresponse=$( /usr/bin/curl
--header "Content-Type: text/xml; charset=utf-8"
--data "${xmlComputerInfo}"
--request GET
--connect-timeout 5
--max-time 10
--user ${jssUser}:${jssPass}
${jssHost}JSSResource/computers/udid/${uuid} 2> /dev/null )
computerName=`echo $theJSSResponse | xpath /computer/general/name[1] | awk -F'>|<' '/name/{print $3}'`
*Note* I have not tested to code. You might need to change some things to make it work for you.
Hope either one of these helps.
I really appreciate the reply's however when running either code i get the following error...
no element found at line 2, column 0, byte 1:
^
at /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level/XML/Parser.pm line 187.
@Potter][/url][/url that is xpath not parsing out the xml properly. what you need to do is just echo out the "theJSSresponse" and see what you need to work with path.
Here is a bit dirtier of markup of the xpath parse.
echo $theJSSresponse | xpath /computer/general/name[1] | sed 's/<name>//g' | sed 's/</name>//g'
I did test the whole script this time, and I can say it does work.
so after troubleshooting i finally got the script to produce the information i was needing...
a huge THANK YOU to @GaToRAiD and @mm2270 for your scripts
I owe you both a beer or drink at JNUC 2015....