#!/bin/bash
#traitement de log.txt et arret de la connexion internet
#
function alerte
{
echo "fonction alerte"
#
#arret de la connexion internet
MACHINE="@ip"
LOGIN="Administrator"
PWD=$LOGIN
COMMANDE="ppp ifdetach"
#
telnet $MACHINE 23
$LOGIN
$PWD
$COMMANDE
exit 0
}
#liste d'ip autorisees
IP[1]="10.0.0"
IP[2]="172.17.0"
IP[3]="172.18.0"
IP[4]="192.168.1"
IP[5]="192.168.20"
IP[6]="192.168.50"
#
#lire le fichier ligne par ligne
cat log.txt | while read ligne
do
i=1
#on récupére la dernière adresse ip
echo $lignerm -rf log.txt
ip=$(echo $ligne | cut -d' ' -f 6)
#
if ["$ip" != "testabessonn"];
then n1=$(echo ${ip} | cut -d'.' -f 1)
n2=$(echo ${ip} | cut -d'.' -f 2)
n3=$(echo ${ip} | cut -d'.' -f 3)
ip_new=${n1}.${n2}.${n3}
#
#on compare les adresses ip
if ["$ip_new" != "IP[1]" || "$ip_new" != "IP[2]" || "$ip_new" != "IP[3]" ||
"$ip_new" != "IP[4]" || "$ip_new" != "IP[5]" || "$ip_new" != "IP[6]"];
then alerte;
fi
fi
done
exit 0
Partager