Hello!
I'm trying to loop through a CSV of device serial numbers, extract those serial numbers as variables, use the variables and the API to get the JSS ID of the mobile devices as another variable, then use this new variable to execute some remote commands on the devices :
#!/bin/sh
while IFS="," read serial; do
echo $serial
jID=$(curl -sku $apiUN:$apiPW -H "Accept: text/xml" $apiURL/JSSResource/mobiledevices/serialnumber/$serial | xmllint --xpath '/mobile_device/general/id/text()' -)
curl -sku $apiUN:$apiPW -H "Accept: text/xml" $apiURL/JSSResource/mobiledevicecommands/command/RestartDevice/id/$jID -X POST
done < ~/Desktop/TestFile.csv
However, whenever I run the script get the following errors :
-:1: parser error : Document is empty
My CSV is a .csv created in excel with a single column of serial numbers and no header. Is it possible that there is an error there? Or can I not loop and use these variables in the csv? The actual command I will be doing for this will be the UnmanageDevice command. The RestartDevice is just to use for testing.
I'm not too well versed with scripting yet and any help would be appreciated!
If there is a better way for me to do this then I am all for it!