Used function to replace repetitive code

pull/3/head
Aaron Johnson 7 years ago
parent dca065ccec
commit eab4dd464a

@ -8,6 +8,11 @@
scan_domain=$1
scan_ns=$2
get_hostip () {
#host_ip=`echo $zone_xfer | grep ${host} | grep A | awk '{print $3}'`
host_ip=`echo $zone_xfer | grep $1 | grep A | awk '{print $3}'`
}
zone_xfer=`dig $scan_domain @$scan_ns AXFR | egrep -v 'SOA|NS|MX|DiG' | grep $scan_domain | awk '{print $1,$4,$5}'`
for host in `echo $zone_xfer | awk '{print $1}'`; do
user_name=$3
@ -16,22 +21,23 @@ for host in `echo $zone_xfer | awk '{print $1}'`; do
if echo $zone_xfer | grep $host | grep TXT; then
if [ "`echo $zone_xfer | grep $host | grep TXT | awk '{print $3}'`" = '"lxc"' ]; then
user_name="root"
host_ip=`echo $zone_xfer | grep ${host} | grep A | awk '{print $3}'`
get_hostip ${host}
alias ${host_short}="${connect_cmd} ${user_name}@${host_ip}"
elif [ "`echo $zone_xfer | grep $host | grep TXT | awk '{print $3}'`" = '"windows"' ]; then
connect_cmd="rdesktop -g 1600x900"
host_ip=`echo $zone_xfer | grep ${host} | grep A | awk '{print $3}'`
get_hostip ${host}
alias ${host_short}="${connect_cmd} -u ${user_name} ${host_ip}"
elif [ "`echo $zone_xfer | grep $host | grep TXT | awk '{print $3}'`" = '"cisco"' ]; then
connect_cmd="telnet"
host_ip=`echo $zone_xfer | grep ${host} | grep A | awk '{print $3}'`
get_hostip ${host}
alias ${host_short}="${connect_cmd} ${host_ip}"
fi
else
host_ip=`echo $zone_xfer | grep $host | grep A | awk '{print $3}'`
get_hostip ${host}
alias ${host_short}="${connect_cmd} ${user_name}@${host_ip}"
fi >/dev/null
done
unset -f get_hostip
return 0

Loading…
Cancel
Save