Getting your wordpress self hosted stats on your console with bash script.

2010-06-29 3 min read Bash Learning

Some time back I wrote a blog on how to get your site stats using curl in <a class="zem_slink freebase/en/bash" title="Bash" rel="homepage" href="http://tiswww.case.edu/php/chet/bash/bashtop.html">bash shell. Today we will use the same script to get the stats every few seconds on the terminal on the same line, similar to progress meter.

Here is the script and the description:

  <td>
    <div class="bash codecolorer">
      <span class="co0">#!/bin/bash -</span><br /> <span class="co0">#===============================================================================</span><br /> <span class="co0">#</span><br /> <span class="co0">#          FILE:  update_stats.sh</span><br /> <span class="co0">#</span><br /> <span class="co0">#         USAGE:  ./update_stats.sh</span><br /> <span class="co0">#</span><br /> <span class="co0">#   DESCRIPTION:  Update the stats inline in shell every $1 seconds.</span><br /> <span class="co0">#</span><br /> <span class="co0">#       OPTIONS:  ---</span><br /> <span class="co0">#  REQUIREMENTS:  ---</span><br /> <span class="co0">#          BUGS:  ---</span><br /> <span class="co0">#         NOTES:  ---</span><br /> <span class="co0">#        AUTHOR:  <a class="zem_slink" title="Amit Agarwal" rel="homepage" href="http://amit-agarwal.co.in">Amit Agarwal</a> (AKA), amit.agarwal@amit-agarwal.co.in</span><br /> <span class="co0">#       COMPANY:  Individual</span><br /> <span class="co0">#       VERSION:  1.0</span><br /> <span class="co0">#       CREATED:  06/21/2010 11:27:16 PM IST</span><br /> <span class="co0">#      REVISION:  ---</span><br /> <span class="co0">#===============================================================================</span><br /> <br /> <span class="re2">sleep_time</span>=<span class="nu0">30</span> <span class="co0">#the time to wait between stats collection</span><br /> <span class="re2">run_stats</span>=get_stats  <span class="co0"># the script to run to get the stats</span><br /> <span class="re2">filename</span>=<span class="sy0">/</span>tmp<span class="sy0">/</span>statpress.html <span class="co0"># the filename where the script is storing the html file of your statpress page.</span><br /> <span class="kw3">eval</span> <span class="re1">$run_stats</span> <span class="nu0">2</span><span class="sy0">><</span>a <span class="re2">class</span>=<span class="st0">"zem_slink freebase/en/dev_null"</span> <span class="re2">title</span>=<span class="st0">"/dev/null"</span> <span class="re2">rel</span>=<span class="st0">"wikipedia"</span> <span class="re2">href</span>=<span class="st0">"http://en.wikipedia.org/wiki//dev/null"</span><span class="sy0">>/</span>dev<span class="sy0">/</span>null<span class="sy0"></</span>a<span class="sy0">></span><br /> <span class="kw1">while</span> <span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span><br /> <span class="kw1">do</span><br /> <span class="sy0"><!</span>--loginview start--<span class="sy0">></span><span class="re2">values</span>=$<span class="br0">&#40;</span><span class="kw2">cat</span> <span class="re1">$filename</span> <span class="sy0">|</span> w3m <span class="re5">-dump</span> <span class="re5">-T</span> <span class="sy0"><</span>a <span class="re2">class</span>=<span class="st0">"zem_slink freebase/en/html"</span> <span class="re2">title</span>=<span class="st0">"HTML"</span> <span class="re2">rel</span>=<span class="st0">"wikipedia"</span> <span class="re2">href</span>=<span class="st0">"http://en.wikipedia.org/wiki/HTML"</span><span class="sy0">></span>text<span class="sy0">/</span>html<span class="sy0"></</span>a<span class="sy0">></span> <span class="sy0">|<</span>a <span class="re2">class</span>=<span class="st0">"zem_slink freebase/en/grep"</span> <span class="re2">title</span>=<span class="st0">"Grep"</span> <span class="re2">rel</span>=<span class="st0">"wikipedia"</span> <span class="re2">href</span>=<span class="st0">"http://en.wikipedia.org/wiki/Grep"</span><span class="sy0">></span><span class="kw2">grep</span><span class="sy0"></</span>a<span class="sy0">></span> <span class="st0">"^Visitor\\|^Pageviews"</span><span class="sy0">|<</span>a <span class="re2">class</span>=<span class="st0">"zem_slink freebase/en/awk"</span> <span class="re2">title</span>=<span class="st0">"AWK"</span> <span class="re2">rel</span>=<span class="st0">"homepage"</span> <span class="re2">href</span>=<span class="st0">"http://cm.bell-labs.com/cm/cs/awkbook/index.html"</span><span class="sy0">></span><span class="kw2">awk</span><span class="sy0"></</span>a<span class="sy0">></span> <span class="co3">\'</span><span class="br0">&#123;</span>print <span class="re4">$1</span><span class="nu0"></span><span class="br0">&#125;</span><span class="co3">\'</span><span class="sy0">|</span><span class="kw2">tr</span>  <span class="st0">"\<span class="es1">\n</span>"</span> <span class="st0">" "</span><span class="br0">&#41;</span><br /> <span class="re2">time</span>=$<span class="br0">&#40;</span><span class="kw2">date</span><span class="br0">&#41;</span><br /> <span class="kw3">printf</span> <span class="st0">"<span class="es2">$time</span> --> <span class="es2">$values</span> \<span class="es1">\r</span>"</span><span class="sy0"><!</span>--loginview end--<span class="sy0">></span><br /> <span class="kw2">sleep</span> <span class="re1">$sleep_time</span><br /> <span class="kw1">done</span>
    </div>
  </td>
</tr>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
\"Enhanced

Minimize the download size for updates.

2010-02-10 1 min read Fedora Linux

Fedora has rolled out presto repositories. What this means to the users is that the download size for the updates would be greatly reduced. To use the feature, first install the yum plugin:

sudo yum install yum-presto.noarch

Presto uses delta rpms. These delta rpms are quite small in size (eg few kbs instead of 15 MB for firefox 3.5). These delta rpms are used to re-create the original rpm and this is completely transparent to the end user. So, next time when you update with the plugin installed you will see the difference in the download size.

Continue reading

Database of vulnurability at milw0rm.com – udpate and makeindex with cron.

2009-09-08 1 min read Bash Uncategorized

I am quite regular visitor of milw0rm and generally try to keep up with the vul&#8217;s. For doing this I wrote a small scripts rather set of scripts to keep myself update.  Here&#8217;s what we are going to do:

  1. Get the latest tar from the site.

  2. Extract it.

  3. Make the index

  4. Have a shortcut to search the index.

Download the attached files for the first 2 points. <a href="http://blog.amit-agarwal.co.in/wp-content/uploads/2009/09/makeindex-milw0rm.sh">makeindex-milw0rm and <a href="http://blog.amit-agarwal.co.in/wp-content/uploads/2009/09/udpate-milw0rm.sh">udpate-milw0rm

Continue reading