[Python-modules-commits] [python-coloredlogs] 03/07: Add checkalive
Gaurav Juvekar
gauravjuvekar-guest at moszumanska.debian.org
Sun Mar 12 20:19:04 UTC 2017
This is an automated email from the git hooks/post-receive script.
gauravjuvekar-guest pushed a commit to branch master
in repository python-coloredlogs.
commit 804923df0b752d9655ce645a04f55e99ffb4d80a
Author: Gaurav Juvekar <gauravjuvekar at gmail.com>
Date: Wed Jan 18 17:02:18 2017 +0530
Add checkalive
---
shell_programming/checkalive.sh | 38 ++++++++++++++++++++++++++++++++++++++
shell_programming/createfiles.sh | 0
2 files changed, 38 insertions(+)
diff --git a/shell_programming/checkalive.sh b/shell_programming/checkalive.sh
new file mode 100755
index 0000000..8f4341d
--- /dev/null
+++ b/shell_programming/checkalive.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+# set -x
+# set -e
+
+is_complete_ip() {
+ count_dots=$(echo "$1" | grep -o '\.' | wc -l)
+ test $count_dots -eq 3
+ return $?
+}
+
+check_ip() {
+ if ping -c 1 -w 5 "$1" > /dev/null 2>&1
+ then
+ echo "$1"
+ fi
+}
+
+
+while [ $# -ne 0 ]
+do
+ if is_complete_ip "$1"
+ then
+ check_ip "$1"
+ shift
+ else
+ base="$1"
+ shift
+ start="$1"
+ shift
+ end="$1"
+ shift
+
+ for ip_range in `seq $start $end`
+ do
+ check_ip "$base.$ip_range"
+ done
+ fi
+done
diff --git a/shell_programming/createfiles.sh b/shell_programming/createfiles.sh
old mode 100644
new mode 100755
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-coloredlogs.git
More information about the Python-modules-commits
mailing list