Skip to content

Instantly share code, notes, and snippets.

@djtecha
Forked from adam-nielsen/get-dell-warranty.sh
Last active August 29, 2015 14:14
Show Gist options
  • Save djtecha/ef62d6c021d8929666bd to your computer and use it in GitHub Desktop.
Save djtecha/ef62d6c021d8929666bd to your computer and use it in GitHub Desktop.
#!/bin/sh
# Warranty request script for Dell PCs
# Written by Adam Nielsen <adam.nielsen@uq.edu.au>
# This code is in the public domain, and is supplied with no warranty.
#
# This script uses Dell's web service to retrieve the most distant warranty expiration
# date for a given machine, as identified by its service tag. It requires curl and awk.
# It doesn't parse the WSDL or anything nice like that, it just sends a precomposed
# request to the server and extracts the relevant info from the response.
SERIAL=$(dmidecode -s system-serial-number)
read -a EVENTS <<< $(curl http://xserv.dell.com/services/assetservice.asmx \
-s -S --data-binary @- --header "Expect:" \
--header "Soapaction: \"http://support.dell.com/WebServices/GetAssetInformation\"" \
--header "Content-Type: text/xml; charset=utf-8" \
<< EOF | awk -F'(</?StartDate>|</?EndDate>)' '{for(i=1;++i<=NF;) if(length($i)==19) print substr($i, 1, 10)}' | sort -nr | sed -n '1p;$p'
<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<n1:GetAssetInformation xmlns:n1="http://support.dell.com/WebServices/">
<n1:guid>11111111-1111-1111-1111-111111111111</n1:guid>
<n1:applicationName>get-dell-warranty.sh</n1:applicationName>
<n1:serviceTags>$SERIAL</n1:serviceTags>
</n1:GetAssetInformation>
</env:Body>
</env:Envelope>
EOF
)
echo "Expiration" ${EVENTS[0]}
echo "Shipped" ${EVENTS[1]}
@djtecha
Copy link
Author

djtecha commented Jan 27, 2015

Modified to output Exp. and Shipped date instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment