vendredi 26 mars 2021

Trying to make a ping .sh script to see if a web is alive by passing a listweb.txt

So i am trying to ping some URL in a list.txt and see if is valid or not code here:

#!/bin/sh

url_list=./listawebmin.txt
contador=0
contadorerror=0
contadorsuccess=0

while read siteurl
do   
    echo "Se va a realizar ping a $siteurl"
    if ping -c3 $siteurl
        then
            echo "---$siteurl SUCCESS---" &>> success.txt
            let contadorsuccess=contadorsuccess+1
        else
            echo "---$siteurl ERROR---" &>> error.txt
            let contadorerror=contadorerror+1          
    fi
    let contador=contador+1
done < $url_list

echo "Total de urls : $contador"
echo "Total de urls SUCCESS: $contadorsuccess"
echo "Total de urls ERROR: $contadorerror"
echo "Servicio Terminado mira error.txt"

The thing is that when i try to pass ping a $something variable that should be for example something=www.google.com in this case, ping does not respond as intended. Saying something like name or severces unidentify (in spanish: : Nombre o servicio desconocido) So the question is how do i make it so it recognise $siteurl ? Is there any better way to verify if a web is alive?




Aucun commentaire:

Enregistrer un commentaire