Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Check a list of serial numbers for eligibility in the 2015 MacBook Pro battery replacement recall
# Returns only eligible serial numbers
# The text file must be formatted with Unix (LF) line breaks
# Usage: /path/to/inputfile.txt
# To output directly to a CSV file: /path/to/inputfile.txt > /path/to/outputfile.csv
# Written by Neil Martin
# With thanks to Nick Tong for his original Jamf EA which gave me the inspiration for this script.
# 2019-06-21
# 2019-06-30 revised to read file directly and avoid problems with filenames containing spaces - thanks to Ben Goodstein.
# Edit the variable below to the filename of your text file containing a list of serial numbers to check
# Do not edit below this line
# Verify the file exists
if [[ ! -e "$file" ]]; then
echo "Serial number list file not found or specified"
echo "Ensure that the filename and path specified are correct"
echo "Script usage: ./ /path/to/file.txt"
exit 1
# Loop through the list and submit data to Apple
while read -r serial || [[ -n "$serial" ]]; do
guid=$(uuidgen | tr "[:upper:]" "[:lower:]")
resp=$(curl -d "$postData" -H "Content-Type: application/json" -X POST "" 2>&1)
if [[ "$resp" == *'"status":"E00"'* ]]; then
echo "$serial,eligible"
elif [[ "$resp" == *'"status":"E01"'* ]]; then
echo "$serial,ineligible"
elif [[ "$resp" == *'"status":"E99"'* ]]; then
echo "$serial,error please recheck"
elif [[ "$resp" == *'"status":"FE01"'* ]]; then
echo "$serial,empty serial"
elif [[ "$resp" == *'"status":"FE02"'* ]]; then
echo "$serial,invalid serial"
elif [[ "$resp" == *'"status":"FE03"'* ]]; then
echo "$serial,error please recheck"
echo "$serial,unknown result please recheck"
done < "$file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment