From 14304bf2aaa58e88f933632df45647f51d705de9 Mon Sep 17 00:00:00 2001 From: John Gaunt Date: Thu, 27 Jan 2022 18:13:29 -0500 Subject: [PATCH] added logic for in stock and message --- ubiquiti_stock.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ubiquiti_stock.sh b/ubiquiti_stock.sh index d587772..143cb90 100644 --- a/ubiquiti_stock.sh +++ b/ubiquiti_stock.sh @@ -7,5 +7,10 @@ SOURCE_FILE='/tmp/source.html' wget -O ${SOURCE_FILE} ${URL} -GREP_RESULTS=$(grep -o '"inventory_quantity":.,' ${SOURCE_FILE} | grep -o '[0-9]\+') +INVENTORY_QUANTITY=$(grep -o '"inventory_quantity":.,' ${SOURCE_FILE} | grep -o '[0-9]\+') + +if [[ ${INVENTORY_QUANTITY} -gt 0 ]]; then + MESSAGE="There are currently ${INVENTORY_QUANTITY} in stock. ${URL}" + echo ${MESSAGE} +fi