I have a problem and it is that when I send a content via bash script , when I receive it by mail nothing comes out and I don't understand what is happening. If someone can help me I would appreciate it very much.
Greetings.
#!/bin/bash
while read line
do
echo $line
ping -c 5 $line > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Hay conexion"
else
echo "KO:" $line > enviar.txt
fi
done < ip2.txt
ssmtp correo a enviar < enviar.txt
This is an assumption, but from the script it would say that all the ips you have in
ip2.txt
work and that's why you don't have anything in the message.Note that you only save to
enviar.txt
when an ip fails. Another thing I've noticed is that if 2 ip's fail you will only get KO'd from one of them.>
replace the file while>>
adding.Finally if there is no line break in the last ip it will not be read.