#! /bin/sh -e # wwwoffle-outgoing-regexp-rm -- # remove WWWOFFLE outgoing requests via regular expression # Copyright : http://www.fsf.org/copyleft/gpl.html # Author : Dan Jacobson -- http://jidanni.org/comp/wwwoffle/ # Created On : Sat Oct 13 04:16:34 2001 # Last Modified On: Fri Jun 10 23:32:17 2005 # Update Count : 121 #Main use: -i: eliminate all those crap requests that seem to accrue #before your next connection #Must be root to use unless you chmod 777 $wwwoffle_cache/outgoing etc. case $1 in -\?|-h|--help) cat <&2; exit 24;} dir=outgoing case $1 in -m) dir=monitor; shift;; esac case $1 in -i) shift #later trigger args warning if $@ not nill set "$@" ${WWWorm_junkstuffs-\ '\\.(css|js|mid|ico|jpe?g|gif|bmp|png|swf|psd|mp3)'\ '$|([./]ads?|count(er)?)[^[:alnum:]]'};; -j) shift; set "$@" 'banner|ads|count|stat|track';; # more filtering -l) shift; set "$@" '.{144}';; # long request filtering -u)wwwoffle-ls $dir|awk '{print $NF}'|LESS=${LESS}F ${PAGER-pager};exit;; "")wwwoffle-ls $dir|awk '{print $NF}'|sort| LESS=${LESS}F ${PAGER-pager};exit;; -*) echo $0: $1: unknown option 1>&2; exit 98;; esac test $# -gt 1 && { echo $0: args too many 1>&2; exit 33;} tmp=/tmp/worr.${RANDOM-x} trap "rm $tmp" 0 gawk="gawk -v IGNORECASE=${IGNORECASE-1} --re-interval" wwwoffle-ls $dir| case $dir in outgoing)$gawk '$6~"'$1'"{print $1,"U" substr($1,2),$6}' > $tmp;; monitor) $gawk '$6~"'$1'"{s=substr($1,2);print $1,"U"s,"M"s,$6}' > $tmp;; esac if test -s $tmp then awk '{print $NF}' $tmp|sort|LESS=${LESS}F ${PAGER-pager} else echo no matches exit 1 fi set -e #again, just to be sure, for all this: echo -n Delete these from $dir request list'? [N]|y ' read answer test "x$answer" = xy cd $wwwoffle_cache/$dir awk '{$NF="";print}' $tmp|xargs rm