I'm trying to write a simple "pinger" script which will periodically try to reach given IP address and output a colored message with information if it is available or not.
I face the problem in which I can't set custom color inside Bash conditional statement. The Bash code has been inserted into execpi variable. Every time when I try to run Conky I get Bash error sh: 1: Bad substitution.
Conky TEXT section:
TEXT
${color grey}Module_1: ${color}: ${execpi 10 if ping -c 1 -W 2 192.168.1.1 > /dev/null; then echo ${color green}"Success"${color}; else echo ${color red}"Failed"${color}; fi} | ${color grey}Module_2: ${color} ${execpi 10 if ping -c 1 -W 2 192.168.1.2 > /dev/null; then echo ${color green}"Success"${color}; else echo ${color red}"Failed"${color}; fi}
Should the ${color}
variables be placed in different way?
Guys from https://ubuntuforums.org help me out. The issue was not-escaped dollar signs inside Bash conditional expresion. Link to my thread and answers: https://ubuntuforums.org/showthread.php?t=2357244. Topic can be closed.