Hi i have to run a automated script for a in-house command of us . the command will list subnets and also give info of each subnet through various options here i had listed the subnets and then greped the names, then checked the info of each subnet and now for each subnet i need to check if dhcp is set to none and we dont have anything mentioned as none it is just "dhcp:" now i need to see if the value is none in the output as like dhcp: not as dhcp:x.x.x.x or dhcp:test.server.com. how can we do that :
#!/bin/bash
cat subnet list | cut -f 2 -d '|' |egrep -v "NAME|^-" |awk '{print $1}' |while read NAME
do
if cat subnet info --name $NAME | grep 'DHCP:' | awk '{ print $2 }' < /dev/null
then
echo dhcp is set to none
else
echo "dhcp is set to a value"
fi
done
fi
done
Here the if statement is wrong because when there is value cat subnet info --name $NAME | grep 'DHCP:' | awk '{ print $2 }'
it shows the value but if loop still shows none
Aucun commentaire:
Enregistrer un commentaire