Skip to content

Instantly share code, notes, and snippets.

@stansidel
Last active December 18, 2015 22:49
Show Gist options
  • Save stansidel/5857642 to your computer and use it in GitHub Desktop.
Save stansidel/5857642 to your computer and use it in GitHub Desktop.
#!/bin/bash
result_file=$(mktemp -t "check_robots_final_XXXXX")
echo "# Checking servers..."
# Need to remove the Windows file endings
sites_file=$(mktemp -t "sites_XXXXXX")
sed 's/^M$//' /www/sitechecker/sites.txt > $sites_file
while read line; do
myfile=$(mktemp -t "check_robotsXXXXXXXXX")
printf "\t$line"
wget -O $myfile "$line/robots.txt" > /dev/null 2>&1
if grep -q "^[^#]*Disallow: /\s*$" "$myfile"; then
echo "$line/robots.txt" >> $result_file
printf " <<<<<<< It has incorrect robots.txt!"
fi
printf "\n"
rm $myfile
done < "$sites_file"
rm $sites_file
if [ -s "$result_file" ]
then
echo "# Sending errors to emails"
mails=`cat /www/sitechecker/mails4external.txt`
/bin/mail -s "There are incorrect robots.txt on the WORKING servers!" "$mails" < $result_file
fi
rm $result_file
echo "# Done"
test.example.com
example.org
ya.ru
market.yandex.ru
google.com
test@example.com test2@example.com test3@example.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment