Explanation: I'm playing a little bit with a script this one helps notifying to user about SSL certificate expiration. If certificate has less than 30 days to expires, this will notify to user, if isn't do nothing.
But for some weird reason validating with a greater constant, even the emails is sending, and this should not happening.
This is the code:
#!/bin/ksh
legend="The next certificate almost expires.\n URL: url.com "
count=30
daysleft=$(./ssl-cert-check -d /etc/ssl/certs/cert.cer | awk '{print $6}' | tail -n 1);
#daysleft=50 #Constant to do some test
sendnot=$(echo $legend | mail -s "url.com SSL cert Expiration" [email protected] < <(./ssl-cert-check -d /etc/ssl/certs/cert.cer))
if [[ $daysleft -lt $count ]];
then
echo "Sending note"
echo $sendnot
else
echo "Doing nothing..."
fi
Doing test with daysleft
constant, the statement it works; but even this anyway is sending the notes to the user.
Edit: The output of:
./ssl-cert-check -d /etc/ssl/certs/cert.cer | awk '{print $6}' | tail -n 1
is 9
Any Questions or comments I will be ready to attending. Regards!!
mail
command unconditionally, before the if-statement. In the command substitution in the assignment tosendnot
.