1
0
mirror of https://github.com/byReqz/conn.git synced 2024-11-01 01:03:14 +00:00

small fixes

- added shebang
- added response if no options or arguments are delivered
This commit is contained in:
Nils 2021-01-15 21:24:10 +00:00 committed by GitHub
parent 951efc6202
commit c3aa98583b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

101
conn.sh
View File

@ -1,47 +1,56 @@
while [ ! -z "$1" ]; do #!/bin/bash
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]];then
echo "Usage: $0 (-m) <ip> (y/n)" while [ ! -n "$1" ]; do
echo "Options:" echo "Usage: $0 (-m) <ip> (y/n)"
echo " -m/--multi -- test multiple ips / disable portscan" echo "Options:"
printf " -h/--help -- show help" echo " -m/--multi -- test multiple ips / disable portscan"
exit echo " -h/--help -- show help"
elif [[ $1 == "-m" ]] || [[ "$1" == "--multi" ]];then exit
echo "multi-ip mode, portscan disabled" done
echo "-------------------Availability----------------------" while [ ! -z "$1" ]; do
fping $@ if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]];then
echo "-----------------------------------------------------" echo "Usage: $0 (-m) <ip> (y/n)"
exit echo "Options:"
elif [[ $1 == "-y" ]] || [[ $1 == "-p" ]] || [[ "$1" == "--portscan" ]] || [[ "$1" == "--yes" ]];then echo " -m/--multi -- test multiple ips / disable portscan"
echo "checking connection status for $2" echo " -h/--help -- show help"
echo "-------------------Availability----------------------" exit
fping $2 elif [[ $1 == "-m" ]] || [[ "$1" == "--multi" ]];then
echo "-----------------------------------------------------" echo "multi-ip mode, portscan disabled"
echo "-------------------Portscan---------------------" echo "-------------------Availability----------------------"
nmap -Pn $2 fping $@
fping -c 4 -A $2 echo "-----------------------------------------------------"
echo "------------------------------------------------" exit
exit elif [[ $1 == "-y" ]] || [[ $1 == "-p" ]] || [[ "$1" == "--portscan" ]] || [[ "$1" == "--yes" ]];then
elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then echo "checking connection status for $2"
echo "checking connection status for $2" echo "-------------------Availability----------------------"
echo "-------------------Availability----------------------" fping $2
fping $2 echo "-----------------------------------------------------"
echo "-----------------------------------------------------" echo "-------------------Portscan---------------------"
exit nmap -Pn $2
else fping -c 4 -A $2
echo "checking connection status for $1" echo "------------------------------------------------"
echo "-------------------Availability----------------------" exit
fping $1 elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then
echo "-----------------------------------------------------" echo "checking connection status for $2"
echo "portscan? (y/n) (default: y)" echo "-------------------Availability----------------------"
read portscan fping $2
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then echo "-----------------------------------------------------"
echo "-------------------Portscan---------------------" exit
nmap -Pn $1 else
fping -c 4 -A $1 echo "checking connection status for $1"
echo "------------------------------------------------" echo "-------------------Availability----------------------"
exit fping $1
elif [[ "$portscan" = "n" ]]; then echo "-----------------------------------------------------"
exit echo "portscan? (y/n) (default: y)"
fi read portscan
fi 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 done