Script estavel e confiável para verificar o seu IP REAL e lhe enviar um email.

Publicado por jacson clemes 04/04/2007

[ Hits: 8.325 ]

Homepage: http://www.orkut.com/Profile.aspx?uid=13137341526100718105

Download VERIFICA_IP.sh




Script estável e confiável para verificar o seu IP REAL e lhe enviar um email.

Sou novato em scripts, então ajudem aí pessoal ;)  Este script usa:

* LYNX para navegar na internet em modo texto. (No Debian o APT resolve)

* MSMTP para mandar email em modo texto (Ver tutoriais ...)

Pode modificar e/ou sugerir melhorias aí.

  



Esconder código-fonte

#######################################################
#######################################################
####                                                        ####
#### Script verifica IP real e manda para o Email             ####
####                                      ####
#### SLAIDEL                                     ####
####                                  ####
#### Vc deve criar os arquivos .ipnovo .ip         ####
#### no diretorio $dir                             ####
#######################################################
#######################################################



#######################################################
#### DIRETORIO
dir=/jacson


#######################################################
#### VAREAVEIS

## Carrega IPs
nip=`cat $dir/.ipnovo`
ip=`cat $dir/.ip`

## Navegador WEB em testo
pega=`which lynx`


#######################################################
## INICIO DO SCRIPT
echo " ##################################"
echo " INICIANDO"
sleep 1

echo " Carregando o site"
$pega lynx -dump http://myip.dk/ |grep -v -i "Your IP:" |grep -v -i "The old site" |grep -v -i "Webhotel" | grep -v -i "Referências" | grep -v -i "http:" > $dir/.ipnovo ;
if [ "$?" == 0 ] # Verifica se o site carregou
 then
   echo " Comparado ..."
   sleep 1

    if [ "$nip" == "$ip" ]
     then
      echo " IP não foi modicidado"
      echo " ##################################"
      exit 
      else
      # Atualiza as variaveis e manda o e-mail
      echo " Atualizando ..."
      sleep 1
      cat $dir/.ipnovo > $dir/.ip
      rm    $dir/LOG/IP
      date >> $dir/LOG/IP
      cat  $dir/.ip   >> $dir/LOG/IP
      echo " Enviando IP para E-mail"
      echo -e "From:SERVER <SEU EMAIL@gmail.com>\nSubject: IP - SERVIDOR AP  \nTo: Gmail <SEU EMAIL@gmail.com> $nip " | msmtp -v "SEU EMAIL@gmail.com"
      echo " O seu novo IP é $nip . "
      echo " ##################################"
      exit
    fi      
    i 
 else
   #Corrige  .ipnovo se nau na procima vex ele manda um email vazil 
   cat $dir/.ip > $dir/.ipnovo

   echo " `date` ERRO " >> $dir/LOG/IP
   


   echo " ERRO!!! O site não está disponivel."
   echo " ##################################"
   exit
fi


## FIM :D
#######################################################
#######################################################

Scripts recomendados

Script para gerar ISO do OpenBSD

Configurar 3G

Pbis open (Likewise)

Baixar música no tramavirtual (wget)

Script para configuracao rapida da eth0


  

Comentários
[1] Comentário enviado por slaidel em 04/04/2007 - 14:55h

Agora acrecentei um while pra garantir q ele vah mandar mesmo o email ...


echo -e "From:SERVER <SEU EMAIL@gmail.com>\nSubject: IP - SERVIDOR AP \nTo: Gmail <SEU EMAIL@gmail.com> $nip " | msmtp -v "SEU EMAIL@gmail.com" ;
while [ $? != 0 ]; do
echo -e "From:SERVER <SEU EMAIL@gmail.com>\nSubject: IP - SERVIDOR AP \nTo: Gmail <SEU EMAIL@gmail.com> $nip " | msmtp -v "SEU EMAIL@gmail.com"
done


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts