Email web statistics from the hosted website using awstats page.

I want to see the stats for my websites mailed to me directly like Google analytics does. Sure enough I can see them on the hosting cpanel page on awstats, but I dont want to check that everyday. An easier solution would be to have that mailed to my email address everyday using cron. Let\’s try to do that today:

First we would need to get the address of the page for the statistics, which would look like this:

So, we download this using the wget program. We would need to supply the username and password to get to the page.  We will use to send the password and the username to get to the page :

–http-user=\”\” –http-password=\”\”

Try to get the page on the command  line once with the complete command:

wget –http-user=\”username\” –http-password=\”password\” \’\’ -O /tmp/aka3 -o /dev/null

This should get the page contents onto file called /tmp/aka3. View the contents in the browser of your choice and ensure that this is what you want 🙂

Now to get the mailing part working. One option is to send the mail directly using sendmail but that will not set the mime correctly for the email and thus your client would display the source code of the page rather than the page. So, we will have to set the mime type and also set the subject line and others. So we will write a script to do that for us. Here\’s the complete script:

wget –http-user=\”username\” –http-password=\”password\” \’\’ -O /tmp/aka3 -o /dev/null
cat <<EOF > /tmp/aka4
To: email address
Subject: Stats for on `date –iso`
Content-Type: text/html; charset=\”us-ascii\”
cat /tmp/aka3 >> /tmp/aka4

Now run this script and you should get an email with subject : Stats for on date

Now put this in cron and you are done.

create SQL-statements from textfile with awk

create SQL-statements from textfile with awk

$ $ awk \'{printf "select * from table where id = %c%s%c;\\n",39,$1,39; }\' inputfile.txt

inputfile.txt is a space-separated textfile, 1st column contains the items (id) I want to put into my SQL statement.

39 = charactercode for single tick \’

1 = first column

If inputfile.txt is a CSV-file separated by \”,\” use FS= to define your own field-separator:

awk \'BEGIN {FS=","; }{printf "select * from table where id = %c%s%c;\\n",39,$1,39; }\' inputfile.txt


by David Winterbottom (





eclim for Fedora – Leonidas – installation.

Here is the installation instruction for Eclim for vim. I have not tried it as I did not require it, but if you need it.

sudo ant -Declipse.home=/usr/lib/eclipse -Dvim.files=/home/amitag/.vim -Dplugins=cdt

create ctgs using

ctags -R /usr/include/