So I am using the API calls to Pull a computer ID. Here is the API Page with the Computer information.
JSSURL:8443/JSSResource/computers/serialnumber/#########/subset/general
-----<computer> --<general> <id>3258</id> <name>Hugonaut</name> <mac_address>##:##:##:##:##</mac_address> <alt_mac_address>##:##:##:##:##</alt_mac_address> <ip_address>#.#.#.#</ip_address> <last_reported_ip>#.#.#.#</last_reported_ip> <serial_number>########</serial_number> <udid>########</udid> <jamf_version>10.#</jamf_version> <platform>Mac</platform> <barcode_1/><barcode_2/> <asset_tag></asset_tag> <remote_management></remote_management> <mdm_capable>true</mdm_capable> <mdm_capable_users/> <report_date></report_date> <report_date_epoch></report_date_epoch> <report_date_utc>#</report_date_utc> <last_contact_time>2018-11-07 10:47:34</last_contact_time><last_contact_time_epoch>1541605654628</last_contact_time_epoch><last_contact_time_utc>2018-11-07T10:47:34.628-0500</last_contact_time_utc><initial_entry_date>2018-08-30</initial_entry_date><initial_entry_date_epoch>1535638796574</initial_entry_date_epoch><initial_entry_date_utc>2018-08-30T10:19:56.574-0400</initial_entry_date_utc><last_cloud_backup_date_epoch>0</last_cloud_backup_date_epoch><last_cloud_backup_date_u/> <last_enrolled_date_epoch>1541603743286</last_enrolled_date_epoch><last_enrolled_date_utc>2018-11-07T10:15:43.286-0500</last_enrolled_date_utc><distribution_point/> <sus/> <netboot_server/> ---<site> <id>-1</id> <name>None</name> </site> <itunes_store_account_is_active>false</itunes_store_account_is_active> </general> </computer>
The problem is when running this bash command it is pulling both the Computer/General ID & the Site ID. I've bolded both. So instead of an output of just 3258, I am getting an output of 3258 -1
Of course I can work around, but how do I get the straight output? What am I doing wrong?
JAMF_ALLCOMPUTERID=$(curl -H "Accept: text/xml" -sfku "${apiuser}:${apipass}" "${jssURL}/JSSResource/computers/serialnumber/${JAMF_SERIAL}/subset/general" | xmllint --format - 2>/dev/null | awk -F'>|<' '/<id>/{print $3}')
example of my workaround, but this just leads to making a bunch of if 1 character else if 2 characters, else if 3 characters, etc and don't want to do that, I need it to work without a workaround.
JAMF_COMPUTERID=${JAMF_ALLCOMPUTERID:0:4}