jeudi 8 janvier 2015

if command "cat /dev/net/tun" result $string then

I'm creating a script which check if a VPS do have TUN driver enabled. The check command is :



cat /dev/net/tun


if it return:



cat: /dev/net/tun: File descriptor in bad state


the module is enabled. otherwise return ERROR.


Here is my script:



tunstring="File descriptor in bad state"
if cat /dev/net/tun | grep -q "$tunstring"; then
echo "GOOOOOD"
else
echo "ERROR"
fi


I get ERROR message.


I tried the same script with a text file and it worked...


Aucun commentaire:

Enregistrer un commentaire