Created
May 25, 2016 05:40
-
-
Save KatelynHaworth/c65329beb6a793f43b0678395f889e44 to your computer and use it in GitHub Desktop.
A simple little tool for the CLI to lookup the model for a Dell system based on its 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/bash | |
# | |
# A simple command line tool to | |
# look the system model for a Dell | |
# service tag | |
# | |
# Usage: | |
# getModelFromServiceTag SERVICE_TAG | |
# | |
# Author: Liam Haworth <[email protected]> | |
# | |
# Copyright (c) Tesserent Ltd, 2016. | |
# | |
if [ -z "${1}" ]; then | |
echo "Parameter 1 must be set!" | |
echo | |
echo "Usage:" | |
echo -e "\tgetModelFromServiceTag SERVICE_TAG" | |
echo | |
echo -e "\tSERVICE_TAG - The service tag for the system to get the model of" | |
echo | |
exit 1 | |
fi | |
model=$(curl -sL http://www.dell.com/support/home/us/en/04/product-support/servicetag/${1} | grep -o "<h3 id=\"ProductName\" class=\"no-margin\">.*</h3>" | sed 's/\(<h3 id="ProductName" class="no-margin">\|<\/h3>\)//g') | |
if [ -z "${model}" ]; then | |
echo "Failed to get a model for the service tag: ${1}" | |
else | |
echo "Dell says that ${1} is a \"${model}\"" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment