How would I loop through a list and ping hosts in the list?
7 replies, posted
I've got a bunch of hosts and I need to know how to get the lowest average by looping through the list. I'd be nice if it would be possible to save the output to a file while at it.
In case someone knows how to do this, here's the list of hosts:
nlams01.sixxs.net
iedub01.sixxs.net
simbx01.sixxs.net
bebru01.sixxs.net
deham02.sixxs.net
ptlis01.sixxs.net
sesto01.sixxs.net
noosl01.sixxs.net
dkcph01.sixxs.net
usqas01.sixxs.net
usbos01.sixxs.net
gblon02.sixxs.net
plwaw01.sixxs.net
uschi02.sixxs.net
dedus01.sixxs.net
usphx01.sixxs.net
usdal01.sixxs.net
frmrs01.sixxs.net
iegwy01.sixxs.net
nlhaa01.sixxs.net
lulux01.sixxs.net
decgn01.sixxs.net
uschi03.sixxs.net
brudi01.sixxs.net
chzrh02.sixxs.net
The '>'s need to be '>>'s.
IIRC, '>' overwrites the file
yeah that's right. I forgot that there was a difference.
Correct me if I'm wrong here, I'm no pro with bash scripting.
In bash script, you can do something like:
[code]
for line in /home/me/hosts.lst do
ping -c 1 $line >> ping.log;
done
[/code]
Then pipe ping.log through a sed substitution / awk / perl script to automatically tell you the lowest value.
[sp]Or maybe i'm totally wrong, then this post is a mindless brain fart[/sp]
[QUOTE=birkett;25192690]Correct me if I'm wrong here, I'm no pro with bash scripting.
In bash script, you can do something like:
[code]
for line in /home/me/hosts.lst do
ping -c 1 $line >> ping.log;
done
[/code]
Then pipe ping.log through a sed substitution / awk / perl script to automatically tell you the lowest value.
[sp]Or maybe i'm totally wrong, then this post is a mindless brain fart[/sp][/QUOTE]
Or just use the sort command to sort the values that it outputs?
[QUOTE=Ayra;25198605]Or just use the sort command to sort the values that it outputs?[/QUOTE]
Much better solution ^^
Nice to see the SixXS guys aren't idiots.
When I entered the place where I live, it told me the only available server is in Amsterdam.
Wrote in the reason box that I only selected it because it was the only one available on the list and there's one in Helsinki which is 150km away from me.
Last night they approved my IPv6 tunnel and the PoP I connect to is the one in Helsinki.
Sorry, you need to Log In to post a reply to this thread.