Phil Newcombe wrote:

Thanks for trying it out. It worked fine for me on my 9.2 box - some minor erroneous ping results but otherwise very helpful. I'm sorry, like I said, I'm no guru. I had to change a couple of the grep lines because, I think, they referred to ping message lines from a different ping than mine. Try pinging something and look at the messages it returns. It should say something like 'round trip time'. I think that is what 'rtt' refers to here. Then you have to change the grep expression to match. If your grep doesn't have a match for 'rtt' it'll probably just die because it seems as each command must complete without error or the following commands make no sense. Upon closer inspection I think I posted the original version and not the one I used. I'll boot up Mandrake to see and get back to you.

--
pn

OK it's the right script but the wrong ping. I'll try to figure out what you need from your previous post.

--
pn


###########################################


#!/bin/sh

# sort_mirrors_by_speed     by A.Mennucci Nov 97
#
# this program is subject to the
#  GNU general public license

#
# this program will scan the file in $1 using
#  grep "\.[a-zA-Z]*:" $1 | awk '{print $1}'
#  to find mirror site host names.
#
#  the string before the  :  character is considered
to be a
#   mirror site host name
#
#  Mirror sites are pinged and statistics  are
collected and sorted #


if [ "$1" = "-h" -o "$1" = "--help" ] ; then echo Usage: $0 mirrorfile echo " Argument must be the file README.mirrors " echo " containing a list of debian mirrors." echo " This program will ping all mirrors with 4 packets" echo " to test their speed and reliability, and then will " echo " sort the result, put it in file mirrors_by_speed and show the best." exit 0 fi


tmpdir=~/tmp


# warning: using the directory /tmp and running this
script
# as root is a potential security problem

if ! [ -w  $tmpdir ] ; then
echo $0 ERROR dir $tmpdir is not writable
echo please create it if it does not exist
exit 1
fi


if [ ! -r "$1" -o "$1" = "" ] ; then echo $0 ERROR Give as argument the file README.mirrors echo " containing a list of debian mirrors" exit 1 fi if [ -r mirrors_by_speed ] ; then echo $0 ERROR the file mirrors_by_speed already exists exit 1 fi

#touch $tmpdir/mirrors_by_speed
n=0

echo -n "Testing "
grep "[a-zA-Z]" $1 | awk '{print $1}' | wc --lines |
tr "\n" " " echo " debian mirror sites for speed and
reliability." echo -n "Tests done : "

#for i in ` grep "[a-zA-Z]*:" $1 | awk '{print $1}' `
;
for i in `grep "[a-z]*" $1 | cut -d"/" -f 1 | awk
'{print $1}' ` ; do
n=`expr $n + 1 `
(
h=$n
#echo TEST $h for $i
#if ping -c 6 `echo "$i" | cut -d: -f 1` >
$tmpdir/ping$$_$h;
if ping -c 6 `echo "$i"` > $tmpdir/ping$$_$h;
then grep "rtt" $tmpdir/ping$$_$h | cut -d"/" -f 5
| tr "\n" " " > $tmpdir/mirrors_by_speed_$h
echo -n " ms AVERAGE ," >>
$tmpdir/mirrors_by_speed_$h
grep "received" $tmpdir/ping$$_$h | cut -d"," -f 3
| tr "\n" "," >> $tmpdir/mirrors_by_speed_$h
echo " SITE $i" >> $tmpdir/mirrors_by_speed_$h
#cat $tmpdir/mirrors_by_speed_$h
cat $tmpdir/mirrors_by_speed_$h >>
mirrors_by_speed
rm $tmpdir/mirrors_by_speed_$h
fi
rm $tmpdir/ping$$_$h
echo -n "$h "
) &
# we do not want to flood the net; we test 30 sites
at a time
# then we wait 8 seconds so that most of the pings
will be done
if [ `expr $n % 30 ` = 0 ] ; then sleep 8 ; fi
done
wait
echo "."
echo "Fastest mirrors are: "
mv mirrors_by_speed mirrors_by_speed~
sort -n mirrors_by_speed~ > mirrors_by_speed
head mirrors_by_speed


# end of scriptd~
sort -n mirrors_by_speed~ > mirrors_by_speed
head  mirrors_by_speed

# end of scriptript

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree



------------------------------------------------------------------------

Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com





------------------------------------------------------------------------


Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com





Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to