[SOLVED] For loop iterating over a list of IP addresses from a txt file
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: CentOS, Mint 18.4, Fedora 27 and Solus
Posts: 6
Rep:
For loop iterating over a list of IP addresses from a txt file
It's me again. I have the script working, but the script is not pinging the address 3 times and moving on to the next address. Also, the message that I want to display before each new ping session is not printing.
As always, any help is great.
Here's the cute little codelette I have so far...
Code:
#!/bin/bash
# Script to test server connectivity using ping
for addr in $(cat vms.txt)
do
echo "Pinging IP address "$addr
ping -c 3 "$addr"
done
Distribution: CentOS, Mint 18.4, Fedora 27 and Solus
Posts: 6
Original Poster
Rep:
Perfect. Thank you. It appears, since I was experimenting with Geany (I use VIM all the time), I hadn't saved the script so the changes were not registering. Thank you for everything! I am the crowned prince of making things harder than they need to be.
Perfect. Thank you. It appears, since I was experimenting with Geany (I use VIM all the time), I hadn't saved the script so the changes were not registering. Thank you for everything! I am the crowned prince of making things harder than they need to be.
perhaps slowing down a bit and double checking your work might help.
No harm no foul.
Cheers!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.