This blog has moved! Redirecting...
You should be automatically redirected. If not, visit and update your bookmarks.

Friday, December 30, 2005

Bash scripting guides

Tuesday, December 27, 2005

Command line search utility

While studying for one of the finals this year, I felt the need for a CLI search utility that would search on Google, Wikipedia, Google Images, etc. I didn't know of any tools that would already do this so I decided to write my own little bash script:

#Needs the htmlview package


#Create the search string
until [ -z "$3" ]

case "$opt" in
"google" )
htmlview\&q="$str"&btnG=Google+Search &

"image" )
htmlview"$str"\&safe=off &

"wpedia" )
htmlview"$str" &

"scholar" )
htmlview"$str"\&ie=UTF-8\&oe=UTF-8\&hl=en\&btnG=Search &

"ieee" )
htmlview\%28\%28"$str"\%29\%3Cin\%3Emetadata\%29 &

* )
echo "Usage: search engine searchterm [searchterms]"
echo "Engines: google Basic Google websearch"
echo " image Unfiltered Google image search"
echo " wpedia Wikipedia (English)"
echo " scholar Google Scholar"
echo " ieee IEEE Xplore (needs subscription)"
echo "Example: search image batman"


exit 0

It makes use of the htmlview package to discover the default browser and display the results. The use of the script is quite straightforward:

[darkknight@darkworld bin]$ search image batman begins

As is, it considers all search terms. Fancy things like Boolean expressions are not supported (yet :)). A copy of the script can be found here.

Time synchronization using NTP

I've been having some trouble getting the system clock to sync. with time servers using ntpd. The method that works at the moment is the use of the CLI utility ntpdate:

[darkknight@darkworld ~]$ sudo su -
[root@darkworld ~]# ntpdate
27 Dec 12:25:17 ntpdate[5743]: adjust time server offset 0.002806 sec
[root@darkworld ~]#

Unfortunately, the man page of ntpdate says that it's set to be removed from the distro. -- hopefully ntpd will work again once that happens.

[Update] It seems the ntpd daemon was missing. The RPM was installed but the daemon was no longer in /usr/sbin/. So, I reinstalled the ntp package and now time sync. works as is should.

Sunday, December 18, 2005

Picture of the Moon

For a while now I've been thinking of photographing the moon. It was a clear night and I finally got around to doing exactly that:

I used my Fujifilm FinePix S5100 (Black&White mode, ISO 200) at a combined maximum zoom of 360x. Then I used Photoshop to increase the contrast a little. I'm quite surprised with the result -- didn't expect this from a consumer grade digicam.