-
Notifications
You must be signed in to change notification settings - Fork 0
/
myping.sh
53 lines (41 loc) · 1017 Bytes
/
myping.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Script Name : myping.bash
# Author : Craig Richards
# Created : September 25, 2011
# Last Modified :
# Version : 1.0
# Modifications :
# Description : Prefixes the ping command with a date stamp, you then prove when it was run, works on Solaris and Linux
#################################
# Start of procedures/functions #
#################################
funct_check_params()
{
if [ ${NARG} -ne 1 ]; then
echo "myping failed : Not enough Parameters passed, you need to add an IP address"
exit 1
fi
}
funct_SunOS()
{
ping -s $IP | while read pong; do echo "$(date +%F_%T) -- $pong"; done
}
funct_Linux()
{
ping $IP | while read pong; do echo "$(date +%F_%T) -- $pong"; done
}
################
# Main Program #
################
# Variable Settings
NARG=$#
IP=$1
{
funct_check_params
if [[ `uname -s` == 'Linux' ]]; then
funct_Linux
elif [[ `uname -s` == 'SunOS' ]]; then
funct_SunOS
fi
}
## End of Script