Network related script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Network related script
# 1  
Old 08-28-2014
Question Network related script

First of all,I would like to introduce about me,

This is my own try and this is not my homework,and I study myself reading shell script pdf guide from net and learn shell scripts bit by bit.I am self study learner.I try to work out shell scripts.please help to resolve this type of problem.when I am struggling

I am using Redhat Linux 4.4 operating system.
I want to ping 16 network ip address from server through shell script.I tried to develop the shell scripts for this reason. But I don't get the output.Please give the shell script for this program.let me know,
I am expecting output like this, for eg:
Code:
this is a server address : 192.168.1.2 

client address : 192.168.1.3 to 192.168.1.19 ( 16 ip address)

I want the output like this:-
  • how many ips are available and list that ips.
  • how many ips are not available and list that ips.

Last edited by rbatte1; 08-28-2014 at 08:41 AM.. Reason: kannansoft1985 - modify : RBATTE1 - added CODE & LIST tags
# 2  
Old 08-28-2014
You could try something like this:

Code:
#!/bin/bash

upcnt=0
downcnt=0
for ip in 192.168.1.{3..19}
do
   if ping -c 1 -W 1 $ip > /dev/null
   then
        let upcnt=upcnt+1
        uplist="$uplist\n    $ip"
   else
        let downcnt=downcnt+1
        downlist="$downlist\n    $ip"
   fi
done

printf "$upcnt ips are available:$uplist\n"
printf "$downcnt ips are not available:$downlist\n"

Note: if not response from a server it will wait up to 1 second to be sure server is unreachable - so maximum runtime should be close to 17 seconds.
This User Gave Thanks to Chubler_XL For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Emergency UNIX and Linux Support

Network related issues

Oflate we are finding a few servers experiencing severe slowness. What would be the commands that I need to try to postmortem the situation? (3 Replies)
Discussion started by: ggayathri
3 Replies

2. Shell Programming and Scripting

need downloading related help...but its not related to unix

Hi All, I am trying to dowmload the zip file "zkManageCustomers.zip " but i dont have access. Can anyone help me to download this file See the below link- http://www.ibm.com/developerworks/opensource/library/wa-aj-open/index.html?ca=drs- Please help me as early as... (1 Reply)
Discussion started by: aish11
1 Replies

3. Shell Programming and Scripting

Query related to ftp script

Hi, I was planning to write a FTP script that will FTP files to destination folder. All configuration should be done through a properties files, I have developed two files under /home/499633/scripts) scripts folder, and my main file(ftp_script.sh) should read the properties from the properties... (2 Replies)
Discussion started by: rahul125
2 Replies

4. AIX

Network related errors

Hi How to check if my AIX server has any network related errors ? (2 Replies)
Discussion started by: samsungsamsung
2 Replies

5. Shell Programming and Scripting

Problem related to shell script

I am new in shell script.I want to write a shell script to read username and password from file and compare it with the username and password which is entered by the GUI application. (1 Reply)
Discussion started by: shubhig15
1 Replies

6. UNIX for Dummies Questions & Answers

script to kill related processes

hi guys, can anyone help me out with the script to kill all the related process at once. i have something like below ps -fu UID PID PPID C STIME TTY TIME CMD xyz 17398 1 2 Dec30 ? 00:31:20 ./psa_mux -simulate -client_ports 22000 xyz 17399 1 2... (2 Replies)
Discussion started by: smithaph
2 Replies

7. Solaris

Solaris 10 network, process, database related comands

Hi everbody, Can anyone let me know the resources for list of network, process, database related commands of solaris10 possibly with little bit of explanation. Thanks in advance, Chandra Sekhar. (1 Reply)
Discussion started by: chandoo.java
1 Replies

8. Shell Programming and Scripting

shell script related query

Hi I have an input to a file. I want the script to return it formatted the input is a number, say , 1234567895 and the output should be 21 43 65 87 59 ,ie, the pair of two digits should be reversed. How can I do this using a shell script? (1 Reply)
Discussion started by: gopsman
1 Replies

9. Shell Programming and Scripting

shell script related to server

I want to run a shell script in such a manner so that if i will run that script on one place than changes related to that will reflect on all the servers in which i want.Is it possible to write such kind of script?Please respond me as early as possble because it is very urgent for me. (2 Replies)
Discussion started by: nitiwari
2 Replies

10. UNIX for Advanced & Expert Users

Model script related question

Hey fellow bit pushers, I have been seeing an odd problem on a few of my systems and was wondering if any of you have seen it on your systems and possibly know why it happens. We have a custom model script for a printer on our systems. This model script is just a standard ksh script... (2 Replies)
Discussion started by: TioTony
2 Replies
Login or Register to Ask a Question