Sponsored Content
Top Forums Shell Programming and Scripting Unix Shell Script to ping systems & make a log Post 302579014 by gokcell on Saturday 3rd of December 2011 09:32:38 PM
Old 12-03-2011
Hi,

Another solution is below.
Put all of your ip address to multiple.txt than run script gokku

Script Code is below. Script is going to sent only one ping packet to remote node. If reply successfull print the UP else Print Down.

Code:
bash-3.00$ more multiple.txt 
10.202.40.53
10.202.40.66
10.202.40.67
10.202.40.55
10.202.40.56
10.202.40.58
10.202.40.59
10.202.40.61
10.202.40.62
10.202.40.38
10.202.40.37
10.202.40.3
10.202.40.1
10.202.40.2
10.202.40.7
10.202.40.5
10.202.40.6
10.202.40.11
10.202.40.9
10.202.40.10
10.202.40.15
10.202.40.13
10.202.40.14
10.202.40.41
10.202.40.40
10.202.40.19
10.202.40.17
10.202.40.18
10.202.40.23
10.202.40.21
10.202.40.22
10.202.40.27
10.202.40.25
10.202.40.26
10.202.40.31
10.202.40.29
10.202.40.30
10.202.40.35
10.202.40.33
10.202.40.34
10.202.40.44
10.202.40.43
10.202.40.64
bash-3.00$ more gokku 

#!/bin/ksh 
count1=0
count2=0
start=`date +"%d-%m-%Y-%T"`
echo
cat multiple.txt | while read line 
do
   sonuc=`/usr/sbin/ping -s $line 64 1 | grep packet | awk '{print $(NF-2)}'`
   if [[ "$sonuc" == "0%" ]]
   then
      count1=$((count1 + 1))
      echo  $line"    "Up"    " 
   else 
      count2=$((count2 + 1))
      echo $line"     "Down"  "
   fi
done
end=`date +"%d-%m-%Y-%T"`
echo
echo Start:$start 
echo End  :$end
echo $count2 side Down $count1 side Up
echo

bash-3.00$ gokku
10.202.40.53    Up      
10.202.40.66    Up      
10.202.40.67    Up      
10.202.40.55    Up      
10.202.40.56    Up      
10.202.40.58    Up      
10.202.40.59    Up      
10.202.40.61    Up      
10.202.40.62    Up      
10.202.40.38    Up      
10.202.40.37    Up      
10.202.40.3     Up      
10.202.40.1     Up      
10.202.40.2     Up      
10.202.40.7     Up      
10.202.40.5     Up      
10.202.40.6     Up      
10.202.40.11    Up      
10.202.40.9     Up      
10.202.40.10    Up      
10.202.40.15    Up      
10.202.40.13    Up      
10.202.40.14    Up      
10.202.40.41    Up      
10.202.40.40    Up      
10.202.40.19    Up      
10.202.40.17    Up      
10.202.40.18    Up      
10.202.40.23    Up      
10.202.40.21    Up      
10.202.40.22    Up      
10.202.40.27    Up      
10.202.40.25    Up      
10.202.40.26    Up      
10.202.40.31    Up      
10.202.40.29    Up      
10.202.40.30    Up      
10.202.40.35    Down    
10.202.40.33    Down    
10.202.40.34    Down    
10.202.40.44    Down    
10.202.40.43    Down    
10.202.40.64    Up      
Start:04-12-2011-05:26:18
End :04-12-2011-05:27:09
5 side Down 38 side Up

Regards,

Goksel Yangin
Computer Engineer

Moderator's Comments:
Mod Comment Thank you for helping (making this only a warning, no infraction), but you should use code tags too, thanks. See your PM for a guide how to use them.

Last edited by zaxxon; 12-04-2011 at 05:18 AM.. Reason: code tags, see PM
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ping from Unix script

I have two queries in regard to a Unix script. 1) From a Unix script, I want to read the IP of another remote HP-UX server and want to just check if that machine is reachable or the IP exists. I don't know the login Id and password of the remote machine. I could not properly manage with ping. How... (2 Replies)
Discussion started by: asutoshch
2 Replies

2. Shell Programming and Scripting

Shell script delete log files from folder & subfolders on space usage

Hi, I am trying to write a shell script to delete logs generate by db when space in the folder reaches 70%. i am getting space values from db, find the files at OS and remove them by using a cron job runs every 5minutes. I have to keep the latest 5 files at any time, my problem is that log files... (3 Replies)
Discussion started by: saha
3 Replies

3. Shell Programming and Scripting

shell script for ping

hi anyone, i want shell script for ping command. any one post here............ (10 Replies)
Discussion started by: rameshreddy.ema
10 Replies

4. Shell Programming and Scripting

Shell Script for ping, Linux

I woul like to create a script in order to make a ping to a server and save in a variable a 1 if respond or a 0 if it doesnt. Then with that I could make a graffic of the server, for how long it is up.:b: So far I have this: if ; then #if the ip respond the ping shows online echo... (3 Replies)
Discussion started by: jsebastiang0
3 Replies

5. Shell Programming and Scripting

Script problems in hp unix systems

test.sh -------------- #This script deletes the temporary files created on the server when the user opens the output files # FILE_PATH=$1 P_FILE_PATH=$2 FRQ=$3 #FRQ=`expr $FRQ*60*24 | bc` #FRQ= 60 echo $FILE_PATH echo $P_FILE_PATH echo $FRQ if then find $FILE_PATH -mmin... (7 Replies)
Discussion started by: arjunbodduuxlx
7 Replies

6. Shell Programming and Scripting

Ping shell script - need urgent help

Hi friends, i have a file contains IP address like below cat file.txt 10.223.20.1 10.223.20.2 10.223.20.3 10.223.20.4 10.223.10.5 . . . like this Now i want to make a script which gives output whether each ip is pinging or not... the result will be like this 10.223.20.1 up... (9 Replies)
Discussion started by: siva kumar
9 Replies

7. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies

8. Shell Programming and Scripting

Shell script to ping multiple servers

Hi I did the following script to ping multiple servers, but I keep on receiveing duplicate emails for one server that is down: #!/bin/bash date cat /var/tmp/servers.list | while read output do ping -c 1 "$output" > /dev/null if ; then echo "node $output is up" else ... (10 Replies)
Discussion started by: fretagi
10 Replies
All times are GMT -4. The time now is 04:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy