perl : Set different TimeZone for script

Here is how to set the timezone inside a perl script. A use case is when the application is communicating with some server in a different timezone and you want to log the time in the timezone of the other end instead of the timezone where this script is running.

$ENV{TZ} = ':/usr/share/zoneinfo/US/Eastern';

Hardware : Dell GX620 SFF HTPC Bootup problem due to burned up capactiors

I added a PCI Express Video card to my Dell GX620 Small Form Factor desktop system and connected it to my Television. One small thing that I completely missed out was the amount of heat that gets generated in such a small confined spot with no outlet for that hot air. And one day it refused to boot up. It will not go to POST. The power LED will come Green, fan on the processor will come on and then switch off. After 3-4 retries it will boot up and display “A Thermal Event has occurred“. But I did not pay attention to that. Silly me. After couple of days it started to take about 20 tries. That’s when I started to search around.

There were so many posts but no real answers. But there was a common lead badmouthing Dell and other PC manufacturers that for saving cost they have used cheap capacitors that burn up.  In my case that was certainly not true. The system had best that market has to offer (Rubycon capacitors) but it was me who managed to burn them off. I got the final on it when I stumbled upon BadCaps.net. A very good website with information on what exactly was going on. So I opened up the system, took out the hard-disk and right under it on the mother board were four capacitors (2200 µF, 6.3V, 10mm) that were popped. The heat from Video card fried the poor chaps as they were too close.

Continue reading “Hardware : Dell GX620 SFF HTPC Bootup problem due to burned up capactiors”

perl : Create unix time from readable time

Many a times you may need to convert the human readable time into the Unix time. When all the information is passed to “mktime” it returns the unixtime. And to reverse it simply use “localtime”. Here is the example.

use POSIX;
use strict;
use warnings;

my $sec = 6;
my $min = 7;
my $hour = 8;
my $day = 9;
my $mon = 10 - 1;
my $year = 2004 - 1900;
my $wday = 0;
my $yday = 0;

my $unixtime = mktime ($sec, $min, $hour, $day, $mon, $year, $wday, $yday);
print "$unixtimen";

my $readable_time = localtime($unixtime);
print "$readable_timen";

Found at http://www.adp-gmbh.ch/perl/posix/convert_time.html

bash : brace expansion for automatic substitution

Bash expands a list of strings separated by commas with in braces to a list of strings separated by spaces. For example

[unixite@theunixtips:~/> echo 111-{aa,bb,cc}+{xx,yy,zz}-222
111-aa+xx-222 111-aa+yy-222 111-aa+zz-222 111-bb+xx-222 111-bb+yy-222 111-bb+zz-222 111-cc+xx-222 111-cc+yy-222 111-cc+zz-222
unixite@theunixtips:~/>

There should not be any space between suffix/prefix and the start/end bracket. Otherwise it is considered as a separate list. Now coming to a real world example where you can make use of this.

mv process.log{,.old} #This will move process.log to process.log.old
mv process.log.{old,oldest} #This will move process.log.old to process.log.oldest

Sendmail : Configure outgoing relay server

Edit following in /etc/mail/sendmail.cf and add the name of your outgoing/relaying mailhost. Ensure that the relay server is accepting your email first.

# "Smart" relay host (may be null)
DS

e.g. if the outgoing relay is mailhost.xyzserver.com sendmail configuration should look like following.

# "Smart" relay host (may be null)
DS mailhost.xyzserver.com

After that restart the sendmail.

/etc/init.d/sendmail stop
/etc/init.d/sendmail start

Hello world!

As usual. The first post.

What great words. Hello World! I can still recall the good old days when the first code was started with printing Hello World! Beginning of the new learning always starts with saying hello to the world. Weather it is a new language (spoken/written) or a computer language (shell, c/c++, perl or even HTML) these are the first words that bring joy to the learner. To me it brings back good old memories when I started to code my first program in Basic. Do people still remember Basic? After that Cobol and Fortran went on the same path as mainframes and dodo.

Anyway this is the start and I close my first post with the great words that someone said Hello World!