Hi
I am trying to write a script that will
1. Get the Web log for today
2. Give me a list of all the IP addresses that have accessed the web server today
3. Remove a list of known IPs listed in a file (line by line)
4. Mail the final file to selected recipients.
I am unable to do part 3. In the script pasted below, I can get only the last IP address removed. It is overwriting the file ipaccess after grepping for each on the known IPs. Can any one help??
Regards
Srini
#! /bin/sh
IP_LIST=/home/ksrinivas/knownips
SOURCE_DIR=/disk2/MUSTANG/
currentDate=`date +%d"/"%b"/"%Y`
awk ' {print $1" "$4" "$7}' /etc/httpd/logs/access_log | sed /exe/D | grep "$currentDate" > $SOURCE_DIR/access.txt
awk ' {print $1}' $SOURCE_DIR/access.txt > $SOURCE_DIR/ip-add
sort -u $SOURCE_DIR/ip-add > $SOURCE_DIR/ips
cat $IP_LIST | while read IP_ADD
do
grep $IP_ADD $SOURCE_DIR/ips > $SOURCE_DIR/ipaccess
done
uuencode $SOURCE_DIR/ips | mail -s "IPs Accessing mywebserver.com today" ksrinivas
I am trying to write a script that will
1. Get the Web log for today
2. Give me a list of all the IP addresses that have accessed the web server today
3. Remove a list of known IPs listed in a file (line by line)
4. Mail the final file to selected recipients.
I am unable to do part 3. In the script pasted below, I can get only the last IP address removed. It is overwriting the file ipaccess after grepping for each on the known IPs. Can any one help??
Regards
Srini
#! /bin/sh
IP_LIST=/home/ksrinivas/knownips
SOURCE_DIR=/disk2/MUSTANG/
currentDate=`date +%d"/"%b"/"%Y`
awk ' {print $1" "$4" "$7}' /etc/httpd/logs/access_log | sed /exe/D | grep "$currentDate" > $SOURCE_DIR/access.txt
awk ' {print $1}' $SOURCE_DIR/access.txt > $SOURCE_DIR/ip-add
sort -u $SOURCE_DIR/ip-add > $SOURCE_DIR/ips
cat $IP_LIST | while read IP_ADD
do
grep $IP_ADD $SOURCE_DIR/ips > $SOURCE_DIR/ipaccess
done
uuencode $SOURCE_DIR/ips | mail -s "IPs Accessing mywebserver.com today" ksrinivas