Reputation: 101
I am having an issue that i cant seem to figure out after a couple hours of tinkering with this. I cant seem this script to return anything to the final column.
#!/bin/bash
file="/Users/USER12/Desktop/url-list.txt"
log="/Users/USER12/Desktop/url-results.txt"
fmt="%-25s%-12s%-16s%-20s\n"
printf "$fmt" DOMAIN_NAME HTTP_CODE RESPONSE_TIME CONTENT_CHECK > "$log"
while read line
do
read code time < <(curl -o /dev/null --silent --head --write-out '%{http_code} %{time_total}' "$line")
curl "$line" 2>/dev/null > /Users/USER12/Desktop/domainQueryString_output.txt
ifStatementConditional=`grep "THE CONTENT I'M LOOKING TO VERIFY" /Users/USER12/Desktop/domainQueryString_output.txt | wc -l`
if [ $ifStatementConditional -eq 1 ] ; then
second_check="online"
else
second_check="DOMAIN IS OFFLINE"
fi
printf "$fmt" "$line" "$code" "$time" "$second_chance" >> "$log"
done <"$file"
It returns the following but nothing to the final column....
DOMAIN_NAME HTTP_CODE RESPONSE_TIME CONTENT_CHECK
google.com 301 1.177
Thanks for the help guys. The Help is Much Appreciated.
Upvotes: 0
Views: 32
Reputation: 60107
You have "$second_chance" where you should have had "$second_check".
Other then that, the following is a better way to do your if
check:
if grep "THE CONTENT I'M LOOKING TO VERIFY" $yourfile -q
then
...
else
...
fi
Upvotes: 2