Skip to content

Commit fa34166

Browse files
committed
Prefixes the ping command with a date stamp, you then prove when it was run, works on Solaris and Linux
1 parent 95b57a5 commit fa34166

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

myping.sh

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

0 commit comments

Comments
 (0)