File: //var/log/spamavoid/review_and_delete.sh
for f in `sort php_execution_block.log | uniq`
do
own=`echo $f | cut -d "/" -f3`
echo "Owner is $own" ;
if [ -f $f ];
then
fsize=$(wc -c "$f" | cut -f 1 -d ' ')
else
echo "File deleted $f" ;
continue ;
fi
echo "File size is $fsize" ;
head -n 35 $f
echo "-------------------------------------------------------------------------------------------------------------" ;
echo "File name $f " ;
read -p "1 - To repair first line: 2 - delete , 3 - change perm 000 , 4 - vim " RESP
case $RESP in
1)
sed -i '1d' $f ;
echo "<?php " > /tmp/newtmp.txt
cat $f >> /tmp/newtmp.txt
mv /tmp/newtmp.txt $f
chown $own:$own $f
;;
2)
grep -v $f php_execution_block.log > tmp.1
mv tmp.1 php_execution_block.log
rm -v $f
;;
3)
chmod 000 $f
;;
4)
/usr/bin/vim $f
read -p "1 - To repair first line: 2 - delete , 3 - change perm 000 , 4 - vim , 5 - ls" RESP
case $RESP in
1)
sed -i '1d' $f ; echo "<?php " > /tmp/newtmp.txt ; cat $f >> /tmp/newtmp.txt; mv /tmp/newtmp.txt $f ; chown $own:$own $f ; ;;
2) rm -v $f ;;
3) chmod 000 $f ;;
5) ls -lh $f ;;
esac
;;
*) echo "doign nothing" ;
esac
clear
done