fixed quotes
This commit is contained in:
@@ -4,29 +4,29 @@ URL=${1}
|
|||||||
PHONE_NUMBER=${2}
|
PHONE_NUMBER=${2}
|
||||||
NAME=${3}
|
NAME=${3}
|
||||||
|
|
||||||
LOG_FILE="/tmp/Ubiquiti-Stock-${NAME}.log"
|
LOG_FILE="/tmp/Ubiquiti Stock ${NAME}.log"
|
||||||
|
|
||||||
echo "" > ${LOG_FILE}
|
echo "" > "${LOG_FILE}"
|
||||||
|
|
||||||
echo "URL: ${1}" | tee -a ${LOG_FILE}
|
echo "URL: ${1}" | tee -a "${LOG_FILE}"
|
||||||
echo "Phone Number: ${2}" | tee -a ${LOG_FILE}
|
echo "Phone Number: ${2}" | tee -a "${LOG_FILE}"
|
||||||
echo "Name: ${3}" | tee -a ${LOG_FILE}
|
echo "Name: ${3}" | tee -a "${LOG_FILE}"
|
||||||
|
|
||||||
SOURCE_FILE="/tmp/source-${NAME}.html"
|
SOURCE_FILE="/tmp/source-${NAME}.html"
|
||||||
|
|
||||||
echo "${SOURCE_FILE}" | tee -a ${LOG_FILE}
|
echo "${SOURCE_FILE}" | tee -a "${LOG_FILE}"
|
||||||
|
|
||||||
wget -qO "${SOURCE_FILE}" ${URL}
|
wget -qO "${SOURCE_FILE}" ${URL}
|
||||||
|
|
||||||
INVENTORY_QUANTITY=$(grep -o -m 1 '"inventory_quantity":[0-9]\+,' "${SOURCE_FILE}" | grep -o '[0-9]\+')
|
INVENTORY_QUANTITY=$(grep -o -m 1 '"inventory_quantity":[0-9]\+,' "${SOURCE_FILE}" | grep -o '[0-9]\+')
|
||||||
|
|
||||||
echo "Inventory Quantity: ${INVENTORY_QUANTITY}" | tee -a ${LOG_FILE}
|
echo "Inventory Quantity: ${INVENTORY_QUANTITY}" | tee -a "${LOG_FILE}"
|
||||||
|
|
||||||
if [[ "${INVENTORY_QUANTITY}" -gt "0" ]]; then
|
if [[ "${INVENTORY_QUANTITY}" -gt "0" ]]; then
|
||||||
MESSAGE="There are currently ${INVENTORY_QUANTITY} ${NAME} in stock. ${URL}"
|
MESSAGE="There are currently ${INVENTORY_QUANTITY} ${NAME} in stock. ${URL}"
|
||||||
echo "Message: ${MESSAGE}" | tee -a ${LOG_FILE}
|
echo "Message: ${MESSAGE}" | tee -a "${LOG_FILE}"
|
||||||
echo "${MESSAGE}" | mailx -r "stockalerts@johnhgaunt.com" --set smtp="smtp.home.johnhgaunt.com:25" ${PHONE_NUMBER}@vtext.com
|
echo "${MESSAGE}" | mailx -r "stockalerts@johnhgaunt.com" --set smtp="smtp.home.johnhgaunt.com:25" ${PHONE_NUMBER}@vtext.com
|
||||||
echo "Email sent" | tee -a ${LOG_FILE}
|
echo "Email sent" | tee -a "${LOG_FILE}"
|
||||||
else
|
else
|
||||||
echo "Not sending email" | tee -a ${LOG_FILE}
|
echo "Not sending email" | tee -a "${LOG_FILE}"
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user