From c3aa98583b7ac82ff049809ef55b48adf371812b Mon Sep 17 00:00:00 2001 From: Nils <32552517+byReqz@users.noreply.github.com> Date: Fri, 15 Jan 2021 21:24:10 +0000 Subject: [PATCH] small fixes - added shebang - added response if no options or arguments are delivered --- conn.sh | 101 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 46 deletions(-) diff --git a/conn.sh b/conn.sh index cb8134e..049937c 100644 --- a/conn.sh +++ b/conn.sh @@ -1,47 +1,56 @@ -while [ ! -z "$1" ]; do - if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]];then - echo "Usage: $0 (-m) (y/n)" - echo "Options:" - echo " -m/--multi -- test multiple ips / disable portscan" - printf " -h/--help -- show help" - exit - elif [[ $1 == "-m" ]] || [[ "$1" == "--multi" ]];then - echo "multi-ip mode, portscan disabled" - echo "-------------------Availability----------------------" - fping $@ - echo "-----------------------------------------------------" - exit - elif [[ $1 == "-y" ]] || [[ $1 == "-p" ]] || [[ "$1" == "--portscan" ]] || [[ "$1" == "--yes" ]];then - echo "checking connection status for $2" - echo "-------------------Availability----------------------" - fping $2 - echo "-----------------------------------------------------" - echo "-------------------Portscan---------------------" - nmap -Pn $2 - fping -c 4 -A $2 - echo "------------------------------------------------" - exit - elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then - echo "checking connection status for $2" - echo "-------------------Availability----------------------" - fping $2 - echo "-----------------------------------------------------" - exit - else - echo "checking connection status for $1" - echo "-------------------Availability----------------------" - fping $1 - echo "-----------------------------------------------------" - echo "portscan? (y/n) (default: y)" - read portscan - if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then - echo "-------------------Portscan---------------------" - nmap -Pn $1 - fping -c 4 -A $1 - echo "------------------------------------------------" - exit - elif [[ "$portscan" = "n" ]]; then - exit - fi -fi +#!/bin/bash + +while [ ! -n "$1" ]; do + echo "Usage: $0 (-m) (y/n)" + echo "Options:" + echo " -m/--multi -- test multiple ips / disable portscan" + echo " -h/--help -- show help" + exit +done +while [ ! -z "$1" ]; do + if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]];then + echo "Usage: $0 (-m) (y/n)" + echo "Options:" + echo " -m/--multi -- test multiple ips / disable portscan" + echo " -h/--help -- show help" + exit + elif [[ $1 == "-m" ]] || [[ "$1" == "--multi" ]];then + echo "multi-ip mode, portscan disabled" + echo "-------------------Availability----------------------" + fping $@ + echo "-----------------------------------------------------" + exit + elif [[ $1 == "-y" ]] || [[ $1 == "-p" ]] || [[ "$1" == "--portscan" ]] || [[ "$1" == "--yes" ]];then + echo "checking connection status for $2" + echo "-------------------Availability----------------------" + fping $2 + echo "-----------------------------------------------------" + echo "-------------------Portscan---------------------" + nmap -Pn $2 + fping -c 4 -A $2 + echo "------------------------------------------------" + exit + elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then + echo "checking connection status for $2" + echo "-------------------Availability----------------------" + fping $2 + echo "-----------------------------------------------------" + exit + else + echo "checking connection status for $1" + echo "-------------------Availability----------------------" + fping $1 + echo "-----------------------------------------------------" + echo "portscan? (y/n) (default: y)" + read portscan + if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then + echo "-------------------Portscan---------------------" + nmap -Pn $1 + fping -c 4 -A $1 + echo "------------------------------------------------" + exit + elif [[ "$portscan" = "n" ]]; then + exit + fi +fi done \ No newline at end of file