mardi 24 septembre 2019

How to write if-else in shell and echo the ouput to a variable

Checking whether the reddis is working using this command

redis-cli ping if output is PONG redis is working.

How to re-write this in shell script like this


#!/bin/bash
redis_metrics=$(redis-cli ping)

if [$redis_metrics == PONG]
then
        echo "100"
else
        echo "0"
fi

Need to assign the echo output value to a variable - redis_status

Aucun commentaire:

Enregistrer un commentaire