script to get all ip addresses of servers into a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to get all ip addresses of servers into a file
# 1  
Old 07-01-2010
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
# 2  
Old 07-01-2010
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

Code:
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


Last edited by funksen; 07-01-2010 at 10:14 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script getting IP's and MAC addresses

Hy over there, Lets make it simple :) Using a bash script, how to grep only the ip address and the mac address and put them in a file:. for example from the dhcp.conf file we got such things: The script will end up with two columns IP's and MAC adresses as it is showed below: ... (9 Replies)
Discussion started by: hermouche
9 Replies

2. Shell Programming and Scripting

Script to overwrite & before that keep copy a file on many servers

I have ssh password less auth enable & script does the job well as well #/bin/bash for i in `cat ip` do scp /etc/resolv.conf root@$ip done But I need to take backup of the file i will overwrite .. is there any simple way ? Kindly respond (5 Replies)
Discussion started by: heman96
5 Replies

3. Shell Programming and Scripting

Need bash script to ping the servers and rename the output file each time the script is ran

HI, I have a file serverlist in that all host names are placed. i have written a small script #./testping #! /bin/bash for i in `cat serverlist` do ping $i >> output.txt done so now it creates a file output.txt till here fine.. now each time i run this script the output file... (4 Replies)
Discussion started by: madhudeva
4 Replies

4. Shell Programming and Scripting

Creating a sed script to change ip addresses in a file

So I'm new to this sed command and I am trying to create a script that replaces ip addresses when I name a file but can't tweak it to work. Here is what it looks like: #!/bin/bash # file=$1 # sed -e 's/-CPUaddr 10.30.10.166/-CPUaddr 10.30.10.151/g' -i "$file" sed -e 's/-CPUaddr... (10 Replies)
Discussion started by: uradunce
10 Replies

5. UNIX for Advanced & Expert Users

Shell script to check the /etc/default/kbd file on a list of SUN servers

Hello, I want to create a shell script that would check the file "/etc/default/kbd" for the entry KEYBOARD_ABORT=alternate on a list of SUN Solaris servers. If this entry is not uncommented (without #) then I should get a message/error report for the host which does not have the setting... (3 Replies)
Discussion started by: mahive
3 Replies

6. Shell Programming and Scripting

Help with script checking for a file in various servers

I am trying to write a script that checks whether or not, a file exists on multiple servers. My code / logic so far is: #!/usr/bin/ksh print "Enter File name to be checked" read MYFILE ssh server1 " cd /var/opt/logs ; if then ... (4 Replies)
Discussion started by: momin
4 Replies

7. Shell Programming and Scripting

Script to SCP a file to multiple servers

Hi All, I am a total noob to the Unix world, and i hope to learn a lot from this wonderful community. Here's my first post and question , i am trying to SCP a file to multiple servers (multiple destinations) through this little script : #!/bin/ksh # copy files # File to be copied... (7 Replies)
Discussion started by: rdlover
7 Replies

8. Shell Programming and Scripting

unix shell script which inserts some records into a file located in remote servers...

All, I need to write an unix shell script which inserts some records into a file located in remote servers. * Get the input from the user and insert according the first row. It should be in ascending order. 123451,XA,ABA 123452,XB,ABB 123453,XC,ABC 123455,XE,ABE 123456,XF,ABF 123458,XG,ABG... (2 Replies)
Discussion started by: techychap
2 Replies

9. Shell Programming and Scripting

Need a sheel script to compare no of file on diffrent servers

i have serverA and serverB and i have a folder with same name an location in both servers.... Now i want to compare files in folder(serverA) with folder (serverB) if there are files missing in folderB then copy those files from folder(serverA) to folder(serverB) (1 Reply)
Discussion started by: ashahzad
1 Replies

10. AIX

Script to ping servers in a file

I would like to ping a list of servers in a text file. Can anyone help? (1 Reply)
Discussion started by: gbarkhor
1 Replies
Login or Register to Ask a Question