Article 4YYYV Pinging Many IP addresses and logging results

Pinging Many IP addresses and logging results

by
Mary777
from LinuxQuestions.org on (#4YYYV)
Hello,
I am trying to ping many IP addresses existing in a text file called "iplist.txt", from a remote server (using telnet to connect to the server), and I want to put the results of the pings in a text file in an organized way that shows the date, time and ping outputs for each IP address.

I am getting an error:
can't read "(cat iplist.txt)": no such variable
while executing
"for addr in $(cat iplist.txt)"


Please any help for getting my final results? and How can I make many a schedule for this script and save each execution outputs in a file without overwriting the old one?

THANK YOU.

Code

#!/usr/bin/expect

# ssh to remote server

spawn telnet XXXX
expect "Username:"
send "XXXX\r"
expect "assword:"
send "XXXX\r"

# Test server connectivity using ping

for addr in $(cat iplist.txt)
do
echo "Pinging IP address "$addr
ping -c 3 "$addr" | while read pong; do echo "$(date): $pong"; done >> capture.txt

donelatest?d=yIl2AUoC8zA latest?i=Q-4QRzVoH9k:ScOD6ZL2zI4:F7zBnMy latest?i=Q-4QRzVoH9k:ScOD6ZL2zI4:V_sGLiP latest?d=qj6IDK7rITs latest?i=Q-4QRzVoH9k:ScOD6ZL2zI4:gIN9vFwQ-4QRzVoH9k
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments