Good morning, I would like to create a script that allows me to ping and traceroute from a list of ip, I have already started to make this little script. the problems I encounter are : that the script pings and traceroutes only the last ip of the file and I can't export the ping results to another file
#!/bin/bash
# in order:
# - saintpierre
# - ping and traceroute saintpierre
FILENAME="./ip/sainpierre/ipsaintpierre.txt"
sudo mkdir ./result/saintpierre/
outputfile="./result/saintpierre/$(date "+%F-%Hh%Mm%S")-$pingtestlogsaintpierre.txt"
for DC in $FILENAME
do
printf "$DC: \t$(ping -i .2 -c 10 -q $DC | awk -F/ '/^round|^rtt/{print $5}') ms\n" | expand -t 20
done >>$outputfile
echo -e "\n"
traceroute $FILENAME >>$outputfile
thanks
Assuming you need to create the path /result/saintpierre/, you need to use -p parameter:
-p will create all folders in path
Since you need to read a file to get all IPs on loop, you have to change to: