#!/bin/sh
########################################
# Description: This script is used to find out how many days are left on the
# Dell warranty.
# Required files: curl, xmlindent, grep, cut, sed, sort, tail, echo
# Last modified: August 25, 2015
########################################
####################
# Set variables
####################
curl=/usr/local/bin/curl
xmlindent=/usr/local/bin/xmlindent
grep=/usr/bin/grep
cut=/usr/bin/cut
sed=/usr/bin/sed
sort=/usr/bin/sort
tail=/usr/bin/tail
echo=/bin/echo
service_tag=$1
url="http://xserv.dell.com/services/assetservice.asmx"
days_left=`$curl $url -s -S --data-binary @- --header "Expect:" \
--header "Soapaction: \"http://support.dell.com/WebServices/GetAssetInformation\"" \
--header "Content-Type: text/xml; charset=utf-8" \
<< EOF | $xmlindent | $grep -e 'DELL\|UNY' \
| $cut -d '>' -f 12 | $sed 's/<\/DaysLeft//' | sort -n | $tail -n 1
11111111-1111-1111-1111-111111111111
$0
$service_tag
EOF`
if [ "$days_left" == "" ]
then
days_left=0
fi
$echo $days_left
exit 0