CLI Color and bash prompt.. some colored fun with prompts in bash

2010-06-29 5 min read Bash Fedora Linux

There are two ways to do it, one is with tput command. We will see that some other time, today we will consider the escape sequence way.

First we need to understand the colors as understood by bash. Some time back a fried of mine gave me this little script to find the colors. You can download it <a href="http://blog.amit-agarwal.co.in/2009/03/bash_colors" target="_blank">Script bash colors. Here is the script

#!/bin/bash

T=&#8217;amit agarwal&#8217;   # The test text

Continue reading

Solaris one liners

2010-06-29 11 min read Solaris

http://www.unixguide.net/sun/sunoneliners.shtml

Unix/Solaris: One-Liners

Source: http://www.kevlo.com/~ebs/unix_commands.txt

Listed here are a bunch of unix commands.

–> change file date stamp

touch –t 199906042020 filename

–> move partitions

ufsdump 0f – /dev/rdsk/c0t0s0s0 | (cd /home; ufsrestore xv -)

–> lay down file system with 1% minfree and inode density

newfs –m1 –i81920 /dev/rdsk/c0t0d0s0

–> check file system

fsck /dev/rdsk/c0t0d0s0

Q: starting sybase

login as sybase, run: ./install/RUN_SYBASE

Q: logging in as sybase sa

isql -U sa

Continue reading

blogtk — Unsupported XML-RPC protocol

2010-06-29 2 min read Linux

Earlier I had talked about this blog client, did I. If not then there is a nice blogging clinet called BloGTK, which can be used directly to post into the blog.

So today I reinstalled it and I was completely at loss with the client being unable to start with the error below:

/usr/lib/python2.5/site-packages/blogtk/BloGTK.py:407: GtkDeprecationWarning: gtk.TRUE is deprecated, use True instead
self.publishCheck.set_active(gtk.TRUE)
Traceback (most recent call last):
File &#8221;/usr/lib/python2.5/site-packages/blogtk/BloGTK.py&#8221;, line 1244, in module
blogtk = BloGTK()
File &#8221;/usr/lib/python2.5/site-packages/blogtk/BloGTK.py&#8221;, line 138, in __init__
self.grabConfig()
File &#8221;/usr/lib/python2.5/site-packages/blogtk/BloGTK.py&#8221;, line 426, in grabConfig
self.rpcServer = proxy.get_xmlrpc_server(self.url)
File &#8221;/usr/lib/python2.5/site-packages/blogtk/proxy.py&#8221;, line 66, in get_xmlrpc_server
return server(url)
File &#8221;/usr/lib/python2.5/xmlrpclib.py&#8221;, line 1414, in __init__
raise IOError, &#8221;unsupported XML-RPC protocol&#8221;
IOError: unsupported XML-RPC protocol

Continue reading

More solaris commands

2010-06-29 2 min read Solaris

These commands are taken from various sources and are quite helpful for day to day work on solaris.

For find n grep

grep -i m_forwardingProxy `find . -name \*cpp`

grep -i XVarBind `find . -name \*h`

grep -i gSLEncodeMode `find .  -name &#8221;*.cpp&#8221; -o -name &#8221;*.h&#8221;`

 
 
Find:

find . \( -name &#8221;*.cpp&#8221; -o -name &#8221;*.h&#8221; -o -name &#8221;*.c&#8221; -o -name &#8221;*.cc&#8221; -o -name &#8221;*.inh&#8221; -o -name &#8221;*.inc&#8221; -o -name &#8221;*.sm&#8221; -o -name &#8221;*.asm&#8221; \)

Continue reading

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

wordpress blog stats monitoring from remote using curl and bash and send it in mail.

2010-06-25 3 min read Bash Fedora Linux

Here&#8217;s something that I had been planning to do for sometime now. I have my blog on wordpress and have Statpress plugin installed. The plugin does give me a good idea of the visits to my site. Now, I have to keep logging in every now and then to check the stats. Also since I did not want to spend some more amount 🙂 so I do not have the shell access to the server, too bad 🙁

Continue reading
Older posts Newer posts