-
-
Save slmingol/bbcad2b30722ab4861229db62f75052b to your computer and use it in GitHub Desktop.
Shell script for retrieving Dell warranty expiration by service tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. | |
if [ -z "$1" ]; then | |
echo 'Use: ./get-dell-warranty.sh <servicetag>' | |
exit 1 | |
fi | |
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"</?EndDate>" '{for(i=1;++i<=NF;) if(length($i)==19) print substr($i, 1, 10)}' | sort -nr | head -n 1 | |
<?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>$1</n1:serviceTags> | |
</n1:GetAssetInformation> | |
</env:Body> | |
</env:Envelope> | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment