Page MenuHomeMusing Studio

findBots.sh
No OneTemporary

findBots.sh

#!/bin/bash
#
# Generates a Go map containing all bots that have accessed Write.as
#
cat /var/log/$1 | grep -i 'bot\|crawler\|voltron' | awk -F\" '{print $4}' | sort | uniq > bots.txt
rm bots.go
cat > bots.go << EOM
package bots
var bots = map[string]bool {
EOM
while read b; do
if [ -n "$b" ]; then
echo " \"$b\": true," >> bots.go
fi
done <bots.txt
cat >> bots.go << EOM
};
func IsBot(ua string) bool {
if _, ok := bots[ua]; ok {
return true
}
return false
}
EOM

File Metadata

Mime Type
text/x-shellscript
Expires
Wed, Feb 11, 5:23 PM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3624018

Event Timeline