Programming in almost language

This is the site where you may share your knowledge and experience to eachother..

  • Categories

  • LinkedIn

  • Tweet Me

  • My footsteps

Shell Script for collecting information from domlogs.

Posted by Pratap on May 18, 2009

Write a scripts which can generate a output for all media/source files which has been downloaded in the month.

This is an easy way I found you may try ==============================================================

#!/bin/bash
filename1=/root/mail_body_file.txt # main file to copy media files name

filename2=/usr/local/apache/domlogs/user/domain.com #domlogs

filename3=/root/out_put.txt # raw out put

filename4=/root/output.txt # final out put

filename5=/root/mail_body_file2.txt # replaced ” ” with “%20”

filename6=/root/mail_body_file3.txt # temp dom log file for search

current_date=”echo `date`”

month=`date | awk ‘{print $2}’`

year=`date | awk ‘{print $6}’`

day=$month/$year
grep $day $filename2 > $filename6
echo “”>$filename3
echo “”>$filename1
echo “”>$filename4

#touch /root/mail_body_file.new
find /home/user/public_html/* -type f | grep -E \.mp3$ > $filename1
find /home/user/public_html/* -type f | grep -E \.midi$ >
mail_body_file.txt
find /home/user/public_html/* -type f | grep -E \.mid$ >>
mail_body_file.txt
find /home/user/public_html/* -type f | grep -E \.swf$ >>
mail_body_file.txt

sed ‘s/ /%20/g’ $filename1 > $filename5
sed “s%\/home\/user\/public_html%\ %g” $filename5
> /root/mail_body_file.new
for i in `cat /root/mail_body_file.new`; #media file anme
do
count=0
for j in `cat $filename6`; # domlogs
do
if [ `echo $i` = `echo $j` ]; # matching string
then
count=`expr $count + 1`
fi
done
echo “$i”, $count >>$filename3 #storing the match in a file as raw output
sed ‘s/%20/ /g’ $filename3 > $filename4 # output to send in mail
done
===========================================================

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: