Building a Finite State Machine Using DFA::Simple

2010-12-15 11 min read Perl

http://www.perl.com/pub/2004/09/23/fsms.html

Building a Finite State Machine Using DFA::Simple By Bill Ruppert on September 23, 2004 12:00 AM I am converting some articles from MS Word to HTML by hand. I often use bulleted outlines so I face a lot of work creating lists with nested sub-lists. It didn’t take opening and closing many

and

  • tags to realize I wanted to automate the task. It’s very easy to use filters with my text editor and I’ve written several in Perl to speed up my HTML formatting. I decided to create a filter to handle this annoying chore. After a little thought I decided the logic involved was just tricky enough to use a finite state machine (FSM) to keep things straight.

    Continue reading

Getting the list of IOCTLS in the kernel.

2010-06-25 1 min read Linux

Sometime back I was helping one of my friends in looking for all the IOCTLs supported by the kernel. Well we did not find the info we were looking for and thus thought to write a perl script to get all the IOCTLS supported by the kernel. Here it is, simple script to scan through the code and give you a list:

#!/usr/bin/perl —

@files = `grep -r ” _IO” /usr/src/redhat/SOURCES/linux-2.6.20/* |grep define ioctls_grep`;
open (DAT, ”ioctls_grep”) ||die ”could not open ioctls_grep”;
@files = DAT;
close(DAT);
my %ioctls_numbers;
print ”Grep completed..\n”;
open (DAT, ”ioctls_numbers_found”);

Continue reading

prints line numbers

2010-05-27 1 min read Bash

$ nl

others:
perl -ne ’print ”$. – $_”’ $1
grep -n . $1
perl -pe ’print ”$. ”’ $1
cat -n $1

  • <a href="http://www.commandlinefu.com/commands/view/4273/prints-line-numbers">View this command to comment, vote or add to favourites
  • <a href="http://feeds2.feedburner.com/commands/by/solarislackware">View all commands by <a href="http://feeds2.feedburner.com/commands/by/solarislackware">solarislackware

<a href="http://www.commandlinefu.com"><img src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/header-logo.jpg" alt="" align="bottom" />

by David Winterbottom (<a href="http://codeinthehole.com">codeinthehole.com)

<a href="http://feedads.g.doubleclick.net/~a/J0FNu7gmMTrQGT61-3dKUYYmlBY/0/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/J0FNu7gmMTrQGT61-3dKUYYmlBY/0/di" alt="" align="bottom" />
<a href="http://feedads.g.doubleclick.net/~a/J0FNu7gmMTrQGT61-3dKUYYmlBY/1/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/J0FNu7gmMTrQGT61-3dKUYYmlBY/1/di" alt="" align="bottom" />

<img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~r/Command-line-fu/~4/L6W6GZj7Dl8" alt="" width="1" height="1" align="bottom" />

Continue reading

Inotify Example - Introduction to Inotify with a C Program Example

2010-05-24 1 min read C Programs Learning Linux

<a href="http://www.thegeekstuff.com/2010/04/inotify-c-program-example/">Inotify Example: Introduction to Inotify with a C Program Example:

<a class="zem_slink freebase/en/inotify" href="http://en.wikipedia.org/wiki/Inotify" title="Inotify" rel="wikipedia">inotify utility is an effective tool to monitor and notify <a class="zem_slink freebase/en/file_system" href="http://en.wikipedia.org/wiki/File_system" title="File system" rel="wikipedia">filesystem changes. You can specify a list of files and directories that needs to be monitored by inotify. This <a class="zem_slink freebase/guid/9202a8c04000641f8000000000023d0f" href="http://en.wikipedia.org/wiki/Library" title="Library" rel="wikipedia">library is used by various other programs. For example, <a class="zem_slink freebase/en/cpan" href="http://www.cpan.org/" title="CPAN" rel="homepage">CPAN module Linux::Inotify is developed based on this library.
iNotify Execution Flow

Continue reading

String and Array Creation

2010-04-28 0 min read Learning Linux Perl
\"Perl\"
Image via Wikipedia

<img src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/perl-one-liners.jpg" alt="Perl One Liners" align="bottom" />This is the fourth part of a nine-part article on famous <a class="zem_slink freebase/en/perl" title="Perl" rel="homepage" href="http://www.perl.org/">Perl one-liners. In this part I will create various one-liners for string and array creation. See <a href="http://www.catonmat.net/blog/perl-one-liners-explained-part-one/">part one for introduction of the series.

Famous Perl one-liners is my attempt to create “perl1line.txt” that is similar to “<a href="http://www.catonmat.net/blog/awk-one-liners-explained-part-one/">awk1line.txt” and “<a href="http://www.catonmat.net/blog/sed-one-liners-explained-part-one/">sed1line.txt” that have been so popular among Awk and Sed programmers.

Continue reading

Script to get the number of events from the logs.

2010-04-11 2 min read Learning Linux Perl

<a id="aptureLink_4P0PJ73NaG" style="margin: 0pt auto; padding: 0px 6px; text-align: center; display: block;" href="http://en.wikipedia.org/wiki/Log%20analysis"><img style="border: 0px none;" title="Log analysis" src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/ph/360x320_WikipediaArticle" alt="" width="360px" height="320px" />

I was trying to do some <a class="zem_slink freebase/en/log_analysis" title="Log analysis" rel="wikipedia" href="http://en.wikipedia.org/wiki/Log_analysis">log analysis and finding the events in the logs. For this the logs had the Events logged as &#8221;|+Event name|&#8221; or with sending and receiving. So I wrote this little script to take care of my requirements.

Continue reading

log analysis with perl and wireshark decode.

2010-04-11 1 min read Linux

Here is something that I had to do in couple of hours to check the logs. The problem was the log file was printing the Received and Sent message in the hex format. I had to verify if the messages were correct. So here is how to do it.

open(FP, &#8221;<$ARGV[0]&#8221;)|| die &#8221;File $ARGV[0] does not exist&#8221;;
while ($line = )
{

if ($line =~ /(Received :)|(Sending :)/)

{

@words = split(/\|/, $words[4]);
$received = $words[1];

Continue reading
Older posts Newer posts