From 2fd36d4af902f5718fe1b171728c8e1fccf14df7 Mon Sep 17 00:00:00 2001 From: ahtlon Date: Sat, 25 Oct 2025 20:01:55 +0200 Subject: [PATCH] Check server status --- pull_info.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pull_info.sh b/pull_info.sh index 31a890e..e599397 100644 --- a/pull_info.sh +++ b/pull_info.sh @@ -1,6 +1,19 @@ +#!/usr/bin/env bash +set -o pipefail echo "Get request cookie" #cookie=$(curl -D - -X GET http://192.168.1.42/wcd/index.html) cookie=$(cat request_example_1.txt) #testing +exitCode="$?" +if [[ $exitCode == "7" ]]; +then + echo "Server offline" + exit 0 +elif [[ $exitCode != "0" ]]; +then + echo "Something went wrong" + exit 1 +fi + cookie=$(echo "$cookie" | grep Set-Cookie | grep -oP "ID=\K[^.]+" ) echo "$cookie"