Fix some casting errors that had never appeared during compilation before. Ever
[aquarium] / ping.sh
diff --git a/ping.sh b/ping.sh
index b87060a..c8b7e63 100755 (executable)
--- a/ping.sh
+++ b/ping.sh
@@ -1,11 +1,49 @@
 #!/bin/bash
+#
+PORT=8888
+SERVER=localhost
+#
+usage() {
+  echo "Usage: $0 [options]"
+  echo ""
+  echo "OPTIONS:"
+  echo "  -s address Server IP address."
+  echo "  -p port    Server port number."
+  echo "  -h         Show this message."
+  exit 0
+}
+#
 function ping {
-   OUT=`curl -s http://localhost:8888/ping/$1  | grep PONG`
+   #echo "SERVER : $SERVER PORT : $PORT" 
+   OUT=`curl -s http://$SERVER:$PORT/ping/$1  | grep PONG`
    if [ "$OUT"  != "PONG" ] ;  
    then
       exit 1
    fi
 }
+#
+while getopts ":p:s:h" opt
+do
+  case $opt in
+    p) PORT=$OPTARG
+    ;;
+    s) SERVER=$OPTARG
+    ;;
+    h) usage
+    ;;
+    :) ERROR="Option -$OPTARG requires an argument. Aborting..."
+    ;;
+    \?) ERROR="Invalid option: -$OPTARG"
+    ;;
+  esac
+done
+
+if [ -n "$ERROR" ]; then
+  echo $ERROR >&2
+  exit 1
+fi
+
+#
 ping aquarium
 ping rabbitmq
 ping imstore