#!/bin/bash # pingTest target error_file_name # Esecuzione test png continuo ad indirizzo indicato, con log su file passato in secondo parametro numPing=60 pingTgt='' logFile='/var/log/pingTest.log' if [ "$2" != "" ]; then logFile=$2 touch $2 #echo "LogFile errori:" #echo $logFile else echo "Manca indicazione logfile!" fi if [ "$1" != "" ]; then pingTgt=$1 #echo "Ping Target" #echo $pingTgt else echo "Manca indicazione target ping!" fi hasError=$(ping -c $numPing -q $pingTgt | grep "$numPing packets transmitted" | grep -v " 0% packet loss") if [ "$hasError" != "" ]; then currentDate=`date` echo $currentDate " | $pingTgt | "$hasError >> $logFile fi