Working with named pipes in Perl

The collegue of mine came across a problem that developed into an interesting solution that I decided to share with the world. Actually, I think the world is pretty much aware of the solution, but just in case that I will ever be looking for this solution again, I’ll have it handy here.

The task at hand was to do some processing of the logs on the fly. The syslog was configured to filter the appropriate logs into a named pipe and a Perl script was written to read from the said pipe and do all the processing.

The original piece of code looked something like this:

open (SYSLOG, "< $named_pipe") 
  or die "Couldn't open $named_pipe: $!\n";

while () {


The problem came with syslog daemon restarts. Every time the syslog was stopped, the EOF was sent to the pipe and the script stopped reading it.

Continue reading “Working with named pipes in Perl”

Daily bookmarks

Today’s links belong to one of the two topics – visual arts or technology.

Visual arts (photography, graffiti, posters, and fashion):


These were shared bookmarks for user tvset on 2005-08-30.

Merging two AVI files

Here is a quick tip if you need to merge two AVI files into one using Linux. In fact, you can glue together more than two files. You can glue together as many as you want.

  1. Install transcode. Actually check if it is already installed first as many distributions include it.
  2. Run the following command: avimerge -o result.avi -i source1.avi source2.avi

avimerge is a part of transcode package.

Trying out Sim

During the last few days I’ve been trying out Sim. Sim is yet another open source Instant Messaging (IM) client that supports a variety of protocols (ICQ, Jabber, AIM, and MSN). I am currently interested only in ICQ though.

Before Sim I’ve been using Licq for a long time and centericq before that.

I switched from centericq to Licq because I wanted to have annoying notifications on new messages while in graphical mode. Otherwise I was constantly forgetting that centericq was running in one my konsoles and it stayed there abandoned for weeks.

Licq is almost perfect for my needs. And I wasn’t looking forward to jumping of off it. It’s just that a few people suggested that Sim is a better client in general, and that is solves a few of those issues that I have with Licq.

Continue reading “Trying out Sim”

Analysis of two perl lines

Today I saw these two lines in one backup script that was written in perl:

my $d = (localtime())[6];
$d = $d=~/[067]/ ? 0 : $d % 2 + 1;

Does this look cryptic to you? Probably not. But I wanted to write something and thought that these two lines won’t be that obvious for everyone out there. So I decided to explain exactly what goes on.

Before I start, I have to say that these are not just any two random lines of perl code. These are very useful lines that provide a short and elegant solution to a rather common problem. Read on if you interested.

Continue reading “Analysis of two perl lines”

Using knotes

KDE has an excellent helper tool – knotes. It a small application that allows one to create notes similar to yellow Post-it that are so familiar to everyone. With knotes it is possible to create notes in all fonts, colors, and sizes as well as set alarms on those notes, display them over all desktops, above or below all windows, etc.

I knew about this application for a long time now, but never got used to using it until recently. After thinking a bit about what kept me away from it, I realized that these were the shortcuts. Particularly, there are two shortcuts which can make all the difference – “New Note” and “New Note From Clipboard”. By default, some weird keys (Alt+Shift+N and Alt+Shift+C) are assigned to these actions. Very inconvenient and non-ituitive.

Using knotes’ configuration dialogue I reconfigured the shortcuts to be F12 for an empty new note and Ctrl+F12 for a new note with clipboard content. That feels way better now. Try it and you’ll be surprised…

P.S.: Now I wisht that knotes could have transparent window background…

SELinux fixes

If you are anything like me and don’t want to disable SELinux upon installation of Fedora Linux, then I have a hint for you.

List all files from selinux-policy-targeted and look at the output. You will the list of all files in the RPM package. Few of those files are SELinux manuals for better tweaking.


I just fixed two problems easily after looking into the documentation.

One was with bind, which was complaining with “Permission denied” on any incoming zone transfer (slave zone). named had all the access there is to all folders, but still couldn’t write. This command (mentioned in man 8 named_selinuhelped immediately:

setsebool -P named_write_master_zones 1

Anoner problem was with Apache, which wasn’t showing anything in user’s public_html directory. man 8 httpd_linux suggested the solution that worked:

setsebool -P httpd_enable_homedirs 1
chcon -R -t httpd_sys_content_t ~user/public_html

Open source is inevitable

Red Hat Magazine says “Open source is inevitable“.

After years of fierce competition, Microsoft and Sun have decided to settle lawsuits and set aside their differences. Why? The answer won’t surprise those who know Linux and open source. Today the customer is in charge. See what happened, how history and the open source movement has helped bring us to where we are today, and why open source is inevitable because it allows the customer to take control.

They also have a nice video clip attached (in QuickTime, RealPlayer, and Ogg Theora downloads or RealPlayer stream).

Searching for packages with apt

Apparently, it is possible to search for packages with apt. Here is it works:

apt-cache search mplayer

Masks are also supported. Consider the difference (package descriptions were removed for cleaner output):

[leonid@ltsp ~]$ apt-cache search lad

[leonid@ltsp ~]$ apt-cache search '^lad'

Timer fix

My new office workstation was behaving very strangely. Once in a while it would slow down to a crawl and hang doing something. I checked the processlist, but nothing was going wrong. I disabled all the services. I checked my scheduled tasks. Nothing. I left it with top running, but it showed that 100% of CPU was idle and more than 500 MBytes of RAM was free. Nothing was eating up resources. Neither was there any significant network traffic. The machine wasn’t swapping or anything. Non-the-less the load average would go up as high as 4.0 or even 7.0!

Continue reading “Timer fix”