How can I pass a single item value from array starting from index/item 0 into function and loop through the array until all items have been passed?
This scripts intended purpose is to pull lines from a text file called array_list and pass them into an array, then perform a function on each array item in a loop until all items have been passed and echo out results to a text file called results.txt showing HTTP Status Codes to associated URL's
#!/bin/bash
#
#Script to lookup URL address and capture associated HTTP Status Code (EG: 200, 301, 400, 404,500, 503)
#
#
declare -a array
array=()
getArray()
{
i=0
while read line
do
array[i]=$line
i=$(($i + 1))
done < $1
}
getArray "array_list"
for url in ${array[@]}
do
function call()
{
curl -s -o /dev/null -w "%{http_code}" $url
}
done
response=$(call)
echo $url $response >> result.txt