Compare commits

...

3 Commits

Author SHA1 Message Date
actions af97e58888 updated hash after commit 2021-12-03 23:18:35 +00:00
Nils bce9576c2d
optimize validate function 2021-12-04 00:17:18 +01:00
Nils e68d8d52b2
make simplified output prettier 2021-11-30 13:35:43 +01:00
2 changed files with 19 additions and 7 deletions

25
conn.sh
View File

@ -108,9 +108,9 @@ function set_argvars {
function validate {
for arg in $@; do
if $(ip route show " $arg" 2&> /dev/null);then
if ip route show " $arg" 2&> /dev/null;then
hosts="$hosts $arg"
elif $(nslookup "$arg" > /dev/null);then
elif nslookup "$arg" > /dev/null;then
hosts="$hosts $arg"
else
echo "invalid input: $arg"
@ -122,11 +122,22 @@ function main {
if [[ $simpleoutput == true ]] && [[ -n $hosts ]];then
echo "-------------------Availability----------------------"
fping $only -e $@
quickport=$(nping $only -c1 -p22,222,3389,135 $@ | grep -e "completed")
if [[ -n $quickport ]];then
echo ""
echo "$quickport"
fi
echo ""
for host in $@;do
linuxping=$(nping $only -c1 -p22,222 "$host")
if [[ -n $(echo "$linuxping" | grep -e "Successful connections: 1") ]];then
echo "$host seems to be booted into a Linux system"
elif [[ -n $(echo "$linuxping" | grep -e "Successful connections: 2") ]];then
echo "$host seems to be booted into the rescue system"
fi
winping135=$(nping $only -c1 -p135 "$host")
winping3389=$(nping $only -c1 -p3389 "$host")
if [[ -n $(echo "$winping135" | grep -e "Successful connections: 1") ]] && [[ -n $(echo "$winping3389" | grep -e "Successful connections: 1") ]];then
echo "$host seems to be booted into Windows"
elif [[ -z $(fping $only -a $host) ]] && [[ -n $(echo "$winping3389" | grep -e "Successful connections: 1") ]];then
echo "$host seems to be booted into (desktop) Windows"
fi
done
echo "-----------------------------------------------------"
else
for host in $hosts;do

1
hash Normal file
View File

@ -0,0 +1 @@
f5ac1039736d88b59101a25c247c8d35