namruf152
March 31st, 2017, 10:19 AM
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:
${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 variable be placed in some different way?
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:
${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 variable be placed in some different way?