• 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
[code]#/bin/sh ping -c 1 nlams01.sixxs.net >> ping.txt ping -c 1 iedub01.sixxs.net >> ping.txt ping -c 1 simbx01.sixxs.net >> ping.txt ping -c 1 bebru01.sixxs.net >> ping.txt ping -c 1 deham02.sixxs.net >> ping.txt ping -c 1 ptlis01.sixxs.net >> ping.txt ping -c 1 sesto01.sixxs.net >> ping.txt ping -c 1 noosl01.sixxs.net >> ping.txt ping -c 1 dkcph01.sixxs.net >> ping.txt ping -c 1 usqas01.sixxs.net >> ping.txt ping -c 1 usbos01.sixxs.net >> ping.txt ping -c 1 gblon02.sixxs.net >> ping.txt ping -c 1 plwaw01.sixxs.net >> ping.txt ping -c 1 uschi02.sixxs.net >> ping.txt ping -c 1 dedus01.sixxs.net >> ping.txt ping -c 1 usphx01.sixxs.net >> ping.txt ping -c 1 usdal01.sixxs.net >> ping.txt ping -c 1 frmrs01.sixxs.net >> ping.txt ping -c 1 iegwy01.sixxs.net >> ping.txt ping -c 1 nlhaa01.sixxs.net >> ping.txt ping -c 1 lulux01.sixxs.net >> ping.txt ping -c 1 decgn01.sixxs.net >> ping.txt ping -c 1 uschi03.sixxs.net >> ping.txt ping -c 1 brudi01.sixxs.net >> ping.txt ping -c 1 chzrh02.sixxs.net >> ping.txt less ping.txt rm ping.txt[/code] you'll have to manually go through it with this script but cba to code too hard right now
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.