I'm trying to create a script that will check a website for a word. I have a few to check so I'm trying to input them via another file.
The file is called "testurls". In the file I list the keyword then the URL. They are separated with a semicolon.
Example Domains;www.example.com
Google;www.google.com
Here is the script:
#!/bin/bash
clear
# Call list of keywords and urls
DATA=`cat testurls`
for keyurl in $DATA
do
keyword=`awk -F ";" '{print $1}' $keyurl`
url=`awk -F ";" '{print $2}' $keyurl`
curl -silent $url | grep '$keyword' > /dev/null
if [ $? != 0 ]; then
# Fail
echo "Did not find $keyword on $url"
else
# Pass
echo $url "Okay"
fi
done
The output is:
awk: cannot open Example (No such file or directory)
awk: cannot open Example (No such file or directory)
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
Did not find on
awk: cannot open Domains;www.example.com (No such file or directory)
awk: cannot open Domains;www.example.com (No such file or directory)
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
Did not find on
awk: cannot open Google;www.google.com (No such file or directory)
awk: cannot open Google;www.google.com (No such file or directory)
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
Did not find on
I've hacked away at this for ages now. Any help is very welcome.
Unix: breakfast of champignons
– jasonwryan Nov 25 '11 at 00:02