script to get all ip addresses of servers into a file

Hi all

i need to create a script that pings every server in my range (0-254) adn then returns the values to a file? can anyone please help. i am working in the tcsh ( and yes i know how to ping ) but i dont know how to ping them all in one script without copying and pasting a 254 times?

can anyone help please?

kind regards.

Brian

that's how I would do it in bash/ksh93, don't know about tcsh, but perhaps you can modify it

it's doing the pings parallel, so you just have to wait a few secs

for (( i=1 ; i<255 ; i++ ))
do ping -c 1 -w 1 xxx.xxx.xxx.${i} 2>&1 > /dev/null && echo "xxx.xxx.xxx.${i} ping ok" >> logfile.txt &
done