Skip to content

Commit

Permalink
add edit check_domain.sh for add curl
Browse files Browse the repository at this point in the history
  • Loading branch information
lex committed Mar 30, 2022
1 parent c9f6402 commit b9c5403
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
1 change: 1 addition & 0 deletions get_ip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ wc -l /tmp/a.txt
125 /tmp/a.txt
./get_ip.sh 8.68s user 7.22s system 44% cpu 36.105 total
./get_ip_cancel_echo.sh 4.29s user 3.69s system 44% cpu 17.943 total
./get_ip_cancel_echo.sh 3.04s user 2.80s system 61% cpu 9.529 total
EOF
43 changes: 21 additions & 22 deletions get_ip_cancel_echo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,38 @@ collect_ip=/tmp/b.txt
dnsserver="119.29.29.29"
# function to get IP address
function get_ipaddr {
local hostname=$1
local query_type=A
ip_address=""
# use host command for DNS lookup operations
#host -t ${query_type} "${hostname}" ${dnsserver} &>/dev/null
#if [ "$?" -eq "0" ]; then
# get ip address
ip_address="$(host -t ${query_type} "${hostname}" | awk '/has.*address/{print $NF}' | sort -rn | awk BEGIN{RS=EOF}'{gsub(/\n/,",");print}')"
#else
# echo "############"
#fi
# display ip
echo "$ip_address"
local hostname=$1
local query_type=A
ip_address=""
# use host command for DNS lookup operations
#host -t ${query_type} "${hostname}" ${dnsserver} &>/dev/null
#if [ "$?" -eq "0" ]; then
# get ip address
ip_address="$(host -t ${query_type} "${hostname}" | awk '/has.*address/{print $NF}' | sort -rn | awk BEGIN{RS=EOF}'{gsub(/\n/,",");print}')"
#else
# echo "############"
#fi
# display ip
echo "$ip_address"
}
true >$collect_ip
awk 'BEGIN{while (a++<50) s=s "-"; print s,"testing output only one",s}'
IFS=' ' read -r -a domain_array <<< "$(cat < $domain_ip|awk '{print$1}')"
IFS=' ' read -r -a domain_array <<<"$(cat <$domain_ip | awk '{print$1}')"
echo "${domain_array[@]}"
awk 'BEGIN{while (a++<50) s=s "-"; print s,"testing output finished",s}'

awk 'BEGIN{while (a++<50) s=s "-"; print s,"testing read from file",s}'
IFS=' '
while read -r domain_array ip_array;do
#echo "domain_array is ${domain_array}"
#get_ipaddr "${domain_array}"
#echo "${domain_array}" "$(get_ipaddr "${domain_array[$i]}")" >>$collect_ip
echo "${domain_array}" "$(get_ipaddr "${domain_array}")" >>$collect_ip
#echo "ip_array is ${ip_array}"
done < $domain_ip
while read -r domain_array ip_array; do
#echo "domain_array is ${domain_array}"
#get_ipaddr "${domain_array}"
#echo "${domain_array}" "$(get_ipaddr "${domain_array[$i]}")" >>$collect_ip
echo "${domain_array}" "$(get_ipaddr "${domain_array}")" >>$collect_ip
#echo "ip_array is ${ip_array}"
done <$domain_ip
awk 'BEGIN{while (a++<50) s=s "-"; print s,"get_ipaddr and collect ip finished",s}'
cat $collect_ip


: <<EOF
wc -l /tmp/a.txt
125 /tmp/a.txt
Expand Down

0 comments on commit b9c5403

Please sign in to comment.