From 53bdc127e8ef069e900c064948df9d7a42a30b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 7 Mar 2024 17:14:24 +0100 Subject: [PATCH] fix function to get ips and hostnames from net --- functions.sh | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/functions.sh b/functions.sh index 76b86e7..44e2b0e 100755 --- a/functions.sh +++ b/functions.sh @@ -1104,7 +1104,7 @@ getfreeip () { local N=$1 - sudo nmap -v -sn -n $1 -oG - | awk '/Status: Down/{print $2}' + nmap -v -sn -n ${N} -oG - | awk '/Status: Down/{print $2}' } @@ -1113,13 +1113,31 @@ getusedip () { local N=$1 local DNS=$2 - sudo nmap -v -sn -n $1 -oG - | awk '!/Status: Down/{print $2}'|while read i;do - echo "$i: $(dig "${DNS:+@}${DNS}" -x $i +short +search)" - + nmap -v -sn -n $1 -oG - | awk '!/Status: Down/{print $2}'|while read i;do + echo "$i: $(dig ${DNS:+@}${DNS:-} -x $i +short +search)" done } +getips () { + + local N=$1 + local DNS=$2 + + nmap -v -sn -n $1 -oG - | while read i + do + j=$(echo "$i"|awk '{print $2}') + case $i in + *Status:\ Down*) + echo "$j: $(dig ${DNS:+@}${DNS:-} -x $j +short +search)" + ;; + *Status:\ Up*) + echo "$j:" + ;; + esac + done +} + function getdbcreds_jra () { local APP_INST=/opt/atlassian/jira local JRA_HOME=$(awk -F "=" '/jira.home/ {gsub(/ /, "", $0); print $2}' "${APP_INST}/atlassian-jira/WEB-INF/classes/jira-application.properties")