|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Member
Iscritto dal: Mar 2006
Messaggi: 61
|
[BASH] Verifica IP in una lista
Ciao a tutti!
Stavo scrivendo uno script che mi risolve un host e mi verifica nel file "lista" se è presente l'indirizzo IP Al momento sono arrivato a questo punto: Codice:
#!/bin/bash IP=`host pippo.com | grep address | awk '{print $4}'` while read LIST_IP; do if [ "${IP}" != "${LIST_IP}" ]; then echo "IP ADDRESS NON PRESENTE NELLA LISTA" else echo "IP ADDRESS PRESENTE NELLA LISTA" fi done < lista | grep -v "#" Il problema è che io vorrei che se anche un solo IP presente nel file "lista" è presente, non deve restituirmi errore. Mi sapreste dare la solita dritta? Grazie come sempre! -w- |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Sep 2005
Città: Torino
Messaggi: 606
|
inserisci un "break" alla fine del corpo dell'else (prima di "fi").
__________________
"Se proprio dovete piratare un prodotto, preferiamo che sia il nostro piuttosto che quello di qualcun altro." [Jeff Raikes] "Pirating software? Choose Microsoft!" |
![]() |
![]() |
![]() |
#3 |
Senior Member
Iscritto dal: Dec 2000
Città: Trento
Messaggi: 5917
|
qualcosa cosi' (non testato)
Codice:
#!/bin/bash IP=`host pippo.com | grep address | awk '{print $4}'` while read LIST_IP; do if [ "${IP}" == "${LIST_IP}" ]; then echo "IP ADDRESS PRESENTE NELLA LISTA" exit fi done < lista | grep -v "#" echo "IP ADDRESS NON PRESENTE"
__________________
Linux User #272700 >+++++++++[<+++++++++>-]<+.++.>++++[<---->-]<++.+++++++. HOWTO: SSH Firewall e DMZ ɐɹdosoʇʇos oʇuǝs ıɯ |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 04:38.