# 11 aug 2023 12:6 am est-not-edt :
# this is comment , this is bash-script for traceroute_beta.htm
# i use example-code in https://drive.google.com/file/d/15NNPBiaGqwA4fVOkSKNbzI3YeFV-UGjs/view?usp=drive_link
# path-to-file-name : school/linux-how-to/abs-guide.pdf
# to run this script : 
# (1)give executable-entitlement to this file with entering linux-command : chmod u+x wget-2.sh
# (2)enter linux-command : source wget-2.sh
# (3)use text-editor like nano-editor.org , firefox , lynx : to check file being created in same directory where wget-2.sh is located .
#
# 11 aug 2023 10:1 pm est-not-edt :
# change date '12 aug 2023 12:6 pm est-not-edt' to '11 aug 2023 12:6 am est-not-edt'
# #reword# (3)check file being created in same directory where wget-2.sh is located .
#     #to# (3)use text-editor like nano-editor.org , firefox , lynx : to check file being created in same directory where wget-2.sh is located .
#
# 13 aug 2023 11:32 pm est-not-edt :
#  new ability : there is checking if file-name already exist or not exit . if file-name already exist then not downloading from toolsip.org .
#   if file-name not-yet exist then download from toolsip.org
#  
#=============================================================================
#!/bin/sh
string_1=a-a-a-a
file_output=test
echo ${string_1//-/=}

ip=( 
#151.101.129.153 #nfl.com#
#204.148.170.126  #ashleyfurniture#
#152.179.50.6
#104.108.110.173
#140.222.225.39 #chickenofthesea
#140.222.225.53
#204.148.170.166
#34.168.205.70
#192.185.187.50 #crownprince.com
#192.185.187.50
#204.148.170.210
#52.93.28.184 #falcon-nw.com
#52.93.28.192
#52.93.28.188
#62.115.123.124 #grahagardadepan.com
#80.91.248.157
#62.115.169.157
#185.230.63.186
54.81.29.56
)

count=${#ip[@]}
index=0
while [ "$index" -lt "$count" ]
do

  ip=${ip[${index}]}
  string_1=${ip//./-}
  file_output="output-"$string_1".htm"

  #if [ "$(whoami)" != 'root' ]; then #from drive.google.com/file/d/15NNPBiaGqwA4fVOkSKNbzI3YeFV-UGjs/view?usp=drive_link   directory  school/linux-how-to/bash-beginners-guide.pdf
   #echo "You have no permission to run $0 as non-root user."
  #fi

  echo "checking existence of file '$file_output'"
  if [ ! -e "$file_output" ]
  then
     #echo 'it'$'\042''s' ${ip[$index]}
     echo "file '$file_output' does not exist , downloading ..."
     string_2="wget -U 'visitor-internet-page-browser = firefox-101.0.1 | visitor-identity = facebook.com/arnon.jaya | \
               visitor-operating-system = linuxmint 18.2 sonya cinnamon' --timeout=10 --tries=1 --no-check-certificate \
               https://toolsip.org/ip/${ip[$index]} \
               --output-document=$file_output"

     echo ${string_2}
     eval ${string_2}

   #  echo "wget -U 'visitor-internet-page-browser = firefox-101.0.1 | visitor-identity = facebook.com/arnon.jaya | \
    #     visitor-operating-system = linuxmint 18.2 sonya cinnamon' --timeout=10 --tries=1 --no-check-certificate \
     #    https://toolsip.org/ip/${ip[$index]} \
      #   --output-document=test"
  else
    echo "file '$file_output' already exist , not-downloading ------ "
  fi
  ((index++))
done
