Lost in Translation...

16th

Nov-2008

Mailing and Telneting with PERL

Jerry Posted in Computer and Internet, Education, Fun, Geekiness, Linux & OpenSource, Network and Security, Testing, tech., work No Comments »

There are many tutorials on the net on how to use the Net::Telnet module to write a script that will automate a telnet session. Perhaps the best place is the CPAN site itself. Though all i needed was a simple script that did the job, i had to scour through many other sites for reference. Finally i’m done with the script that will telnet to the server collect the logs and then mail it to the id that i specified.

I wrote the working version as two perl scripts. I still dont know why i did that, may be for the simplicity sake.

  • log.pl  => does the telnet to retrieve the logs and mail it to me
  • run.pl => which runs the log.pl every hour

So here is the code -

log.pl

#!/usr/bin/perl
use Telnet;
# ---------------------------
$date = `date`;
chop $date;
$mailId = "jerry\@jerrymannel.com";
$cmd = "cat in.log | mail ".$mailId." -s \"Logs - ".$date."\"  ";
# ---------------------------
$host = "192.168.1.100";
$port = "2300";
$uid = "jerry";
$pwd = "password";
open $inputLog,  ">in.log";
$box = new Net::Telnet();
$box->open(     Host => $host,
                Port => $port,
        );
$iLog = $box->input_log($inputLog);
$flag = $box->login(    Name => $uid,
                        Password => $pwd,
                );
$box->print("co");
$box->waitfor('/# $/i');
$box->print("show load;show cpu");
$box->waitfor('/# $/i');
$box->print("show log");
$box->waitfor('/# $/i');
$box->close;
# MAIL section
system $cmd;
exit

run.pl

#!/usr/bin/perl
while (1)
{
        $date = `date +%M%S`;
        chop $date;
        #print $date." - ";
        if ( $date eq "0000" )
        {
                print "Sending the mail @ - ".(`date`);
                system("./logs.pl");
        }
        sleep(1);
}

The script was run on a Linux machine. So i neednt worry about the ‘date’ command and getting the date printed out in a fashion that i needed.

:) Drop in a line of you have more queries on the script. Always happy to help.


11th

Nov-2008

Telnet Scripting Tool a.k.a TST10.exe

Jerry Posted in Computer and Internet, Fun, Geekiness, Linux & OpenSource, Network and Security, Science and Tech., Session/Workshop/Talk, Testing, Windows/Microsoft, tech. 1 Comment »

I have been thinking for a long time that i need to write about this tool that i found. Its quite interesting that this tool is really helpful in automating many of the routine sessions that i as a tester came across. This is by far the best automation tool that i found for telnet sessions.

Imagine these scenarios :

  • You need to do BSO authentications frequently when you switch networks
  • Get intermittent logs from the server for analysis
  • Run automated tests on remote systems (something which i have started to call as run-and-forget)
  • stuck in traffic…no way

Lets get into what this tool is and how to use it.

The tool is for windows (one of the things that i felt bad). To make use of this tool, u will need the exe file, i.e., tst10.exe and an input commands file. The input file will has the first line as the hostname/IP and port, which is followed by alternating SEND and WAIT commands.

Consider this example. I need to connect to a server of IP - 192.168.1.100, where a telnet service is running at PORT - 2300. This is how my script/input file will look like :

192.168.1.100 2300
SEND "\m"
WAIT "login:"
SEND "admin\m"
WAIT "Password:"
SEND "admin1\m"
WAIT "s1#"
SEND "co\m"
WAIT "s1(config)#"
SEND "show load; show cpu\m"
WAIT "s1(config)#"

“\m” = \n in C/PERL/Java/most programming langunages = CR or in non-techie terms “Enter”. SEND, sends the commands to be executed and the WAIT that follows tried to match the string in the output of the SEND commands before it.

How to run it?. There are 2 ways to do it. You can open up the command prompt navigate to the directory where the files are and then issue this command -

tst10.exe /r:IN /o:OUT

where IN is the input file and OUT stores the complete output of the session, so that you can skim through the file and have a look at what happened. OR, put the command in a batch file and double click it every time you need to run it.

Here is the screen capture -

TST10 Screen Capture

TST10 Screen Capture

How is it different from Net::Telnet module of Perl or something similar in TCL or Python? Think about it.

  • Time to write the code - 30min to ? depending upon how complex the situation is
  • Trying to match the output to with REGEX, which means that you need to spend time in coming up with the right regex. Now you have 2 problems in hand
  • Testing time to make sure that the script is robust enough

So this is perfect! NO. This doesn’t work for ssh sessions. Since telnet is getting substituted by ssh in most of the servers due to the secure nature of the connection its kind of difficult to fit it in a normal installation of Linux. I’m not sure about the telnet-ssh thingie happening in Solaris or any of the other servers.

Is there something like this for Linux? :( No. Hey, but look at it this way. Its some relief for us on windows platform for scripting.

You can build complex automatons with this combined with a little bit of Perl and Outlook. Here is one typical scenario that i made and which i have presented as a white-paper.

  • Outlook has a setting that detects for incoming mails with a specific subject line.
  • When the mail comes it evokes a Perl script.
  • The Perl script will go ahead an call the TST’s batch file, which initiates the TST10 session, connects to the remote server starts/runs the automation. The output will be stored in OUT file
  • The Perl script will skim the OUT file for any errors reported during the run.
  • Then it calls an FTP script that will go ahead and get the log files from the remote system
  • The log files are read, the results extracted and neatly formatted into mail and send to the required email-ids

:) sounds complex, but this script gave me enough time to hut for a new job and quit the previous employer.

Who wrote this? Someone by the name of Albert Yale. His home page is - http://ay.home.ml.org/, sadly the site is no longer online.

What happened to the white-paper? It got rejected ;) , humor was not the order of the day.

Download TST10 : tst10.exe | tst10.zip


30th

Oct-2008

Writer’s Block : WTF !!!! Fuck it, I’m back

Jerry Posted in Advice, Blogging, Celebrations, Computer and Internet, Cultures, Entertainment, Freedom, Friends Blogging, Fun, Geekiness, Life, Love, ME, Thoughts, Town & City Life, blog, friends, stupidity No Comments »

 Writers Block : WTF !!!! Fuck it, Im backI was there. It didn’t feel great.

I was scared, i was lost, i was wandering in the dark.

I hit the Writer’s Block.

Trust me its a damn scary place. Felt good when i reached there, mainly due to the fact that i was busy at work and i was in no way even getting time to pee. Forced into the dark the force grew weaker in me. Two days back i faced the bitter reality that i had hit the block, i shouldn’t have taken the left turn at the T-junction at the dead-end, for what joy?, i have no idea.

Goddess Wikipedia (a.k.a. Goddess Saraswathi in Hindu Mythology), describes Writer’s Block as :

Writer’s block is a phenomenon involving temporary loss of ability to begin or continue writing, usually due to lack of inspiration or creativity.

Naah!!! Nothing of these caused my condition. I had inspiration(lots of it) and i had lots to write but i didn’t. Why? I needed a reason and today i have a reason to write. Breaking the door, like Rajani, i’m out with the reason i needed (I wish it was more like a girl that i walked out with).

20th Sept, 15th Oct and this one on the 30th of Oct, that was the frequency of my posts in the last 2 months.

Looking back i ponder what made me stop, was it the work or was it something more noir. Yes, work was one of the reasons, undeniably. 20+ hrs of working on a single day, my friends began referring me as IBM’s bitch. Getting adjusted to the new life was one definite factor. But when i search deep it was something more than that. One that pains me still, tried shrugging it off, but couldn’t, it still lingers in the darkest thoughts. It can be described as one that is scariest for a writer. I was never credited for something that i wrote. Even my closest friends didnt acknowledge the fact that it was me. Bang! i got a “500 Internal Server Error” when i was expecting a “200 OK” with “Connection: Keep-Alive”.

Any way its all behind me, and i at least think that i’m back.

BTW my lingo has now been reduced into the results of an aftermath of heavy AS2/AS3 testing, with heavy dosage of XML and Development team that doesnt consent to bugs.

Taken this opportunity, if u would like anyone who is coming across this post to share, what made them hit writer’s block and how they did eventually overcome it….

:)


15th

Oct-2008

Google Maps XKCD

Jerry Posted in Art, Computer and Internet, Entertainment, Fun, Geekiness, Men, Sexs, Town & City Life, Women 1 Comment »

I’m still recovering out the laugh attack that i had in the morning …

Going West

More at XKCD


20th

Sep-2008

Love Story 2008 - High Cohesion, High Coupling !

Jerry Posted in Celebrations, Cultures, Friends Blogging, Fun, Geekiness, Love, Marriage, Men, Sexs, Town & City Life, Women, fiction, friends, reading 6 Comments »

Alluwahlia Singh, the malayali, is a born techie. He speaks a dialect of English that only an Itanium-based server can decode. He is destined to be one of the greatest programming minds of his time. At
the age of 15, he got his first computer, and ever since it was his only love. They spent sleepless nights traveling through the endless world of computers and technology.

Some say, when he snores you can actually decode it as a binary code to print Fibonacci series, infinitely. When asked, he would say even before he could ever perfect the program or rather his snore, he had to wake up. Yes, he was that kind of guy.

It was the summer of 2008, May 27th. At work, Alluwahlia was deeply lost in thought. He was about to crack the Public-Key encryption and prove it as faulty. His 7th sense (the 6th sense was used for coding, so his actual 6th sense switched to the next available slot) registered the transient state of divine matter. He was startled by the effect that it left on his senses. He felt something hard in his pants. As he checked what it was, he promptly found his lost keys. His friends were amazed at the transition. Alluwahlia couldn’t believe it. So he began backtracking the logs that he had collected.


She was never meant to be a techie. Her delicate fingers were not the best for crunching keys, nor were those hazel eyes meant to look at the monitor. She was caring, affectionate, loving and sweet. Swaroopa was made by the Gods with love. She was everything that a guy could ever ask. And they say she causes half of the traffic jams in Bangalore. Yes she can’t drive if her life depended on it!

Still in the summer of 2008, May 27th. At work, Swaroopa couldn’t take the heat from the CPU anymore. She decided to take a break. If she hadn’t decided to go out at exactly 3:55:36 pm (milisecond precision is unavailable at the time of writing this post) her life would have remained the same. But things were destined to change. On her way out, she spots something — or rather someone — all engrossed in the work. (Un)fortunately, that thing — or rather he — was the most beautiful creature she had ever seen in her life. Men at Work always turned her ‘ON’. In a second, she stopped, glanced at him, and left a sigh wishing he was her’s.

Little did she realize that the butterfly-effect of the ’sigh’ would change the course of her life for ever.


In his abode, he scrambled through what he had. His 7th sense told him he was close. Yes there it was a message at around the same time he felt the ‘force’. It read, “I wish he was mine!”. The 6th sense went into overdrive and nearly took over his 7th sense as he figured out that it was a ‘Sigh’ and it came from — his heart skipped beats — on a trembling screen he read “S…W…A…R…O…O…P…A…SWAROOPA”. He trusted his computer and his calculation.

Jumping out of his seat, he ran out and hopped on to his blue Bajaj Enticer. Sensing the ‘master’, the bike auto starts and greets him, with a “Hello Allu!” in a female voice. Ignoring it all, he punches
something into his mobile and with the help of a divine navigational service (known to mankind and lesser mortals as Google Maps) he triangulates her position on the Vodafone network.

He was motionless as reality hit him. “What? She lives a kilometer away?”

Referring to his bike he mouths the command. “Bluey — take me to your master’s love”.

And loverboy on aforementioned Bluey sped — actually rocketed — towards NGV from Maharaja even before the cops in Bangalore could go “yenu speedu saar!”

Meanwhile, dreaming of the techno-man she saw at work, Swaroopa was lost in her own world, when she heard the roar of a bike. Looking down from her balcony, she couldn’t believe her eyes. Yes it’s Alluwahlia. She looked at him and gave a ’sign’ that almost crashed his system. But he decoded it with the 16-bit processor from the car that was parked nearby.

The message read, “Darling without you I’m NULL. You complete my C Programs with a semi-colon. I will always return(0) when i’m with you. Never will I ever cause any segmentation faults. My Love, My CPU, please initiate the steps to de-allocate me from his 32-bit space and re-allocate me in your giga-byte heart. assert(”Please”);”

Using the advanced predictive text of his E71 phone, he scripted the perfect Perl script to get her down. That was the beginning of the most wonderful love story in the techie world.

His friends found them drunk in each others love, and also found them drunk in each other drinks, at the Legends of Rock. She was laughing non-stop and he, by her side, talking about his latest hack.

They played Wall.E and Eve in the shambles of Kanakpura Road.

Their fun was short lived. He got a call from the parent process and had to leave in a short time. With a 98% utilization of his memory, he left Swaroopa back and flew. And with memory filled of love — virtual memory inclusive — she waits indefinitely, a blocking call without a timeout, for the return invocation.

return(0);

P. S.: However, as most projects in Bangalore, by the time this blog post was scripted, Swaroopa fell for the writer. Alluwahlia self-discontinued himself and is now an obsolete, end-of-life legacy system with no interfaces or support.

(This post has been co-authored with 2s)


18th

Sep-2008

A Twitter Message

Jerry Posted in Blogging, Browsers, Computer and Internet, Entertainment, Fun, Geekiness, Window's Message 2 Comments »

So happy that i’m having net at home, i try and open Twitter.

Guess what this is the message that i get…

twitter-300x248 A Twitter Message

What are the chances …


5th

Sep-2008

My Fav XKCD Comic Strip

Jerry Posted in Computer and Internet, Entertainment, Fun, Geekiness, reading, tech. No Comments »

Just read along the 1337 series

Part - 1

1337: Part 1

Part - 2

1337: Part 2

Part - 3

1337: Part 3

Part - 4

1337: Part 4

Part - 5

1337: Part 5

Simply awesome …


4th

Sep-2008

Google Chrome - First Impressions

Jerry Posted in Browsers, Computer and Internet, Fun, Geekiness, Linux & OpenSource, Review, Science and Tech. No Comments »

chrome-205_noshadow Google Chrome - First Impressions

What should i comment on this browser. First thing that caught my attention was the cool technology that went into this beautiful little app. Remember the days when we used IE, then Fx came along and just tripped and toppled our whole browsing experience. Fx came up with the idea of tabs, imporved browsing experience, plugins etc. etc. You name it they had it, or rather they were ready to include that in their next realease.

I feel the same when i see Chrome or Google Chrome. Its the coolest idea that we can have for a browser at this point. A browser that doesnt crash or rather does a good crash. It never affects any of your other open sessions.

(Read the Chrome story)

The best fact - its open source. That means that even my granny can get the source code and help Google imporve it or can come out with her own Hare-Rama-Rahe-Krishna Browser for the religious kind.

After the initial interations with other users over twitter. I found that people have some common issues, worries, concerns etc etc and not to mention a funny stuff too.

Prasanth a fellow Mutineer, found the shift to Chrome taking a toll on his mental heath, it was too mentally tiring for him.

Sivaprasad was able to download the online installer, but as he was sitting behing a proxy and had to authenticate the installer didnt finish what it had started. He was kind enough to send in the fix for the problem which he found here.

For all those who need a complete offline installer, i have uploaded the same in my site and is awailable for download at this link - Chrome Download. This was Allajunaki’s idea

Interestingly Kiruba reported and error thrown by Chrome that read - “Google Chrome has encountered a problem and needs to close. Please tell Microsoft about it”. :D

Waiting for more reactions…

(first post on/using/with Chrome)

Chrome Offline installer Download


1st

Aug-2008

The Blogging Session Slides

Jerry Posted in Blogging, Education, Entertainment, Freedom, Friends Blogging, Geekiness, ME, Media, Mutiny.in, Report, Session/Workshop/Talk, blog, friends 1 Comment »

This one is a general intro to blogging. Its the same one that i did at Wipro but with modifications.

I have the Calvin and Hobbes theme for this one.

This is the Blogging for Business slides. Its Dilbert themed


18th

Jul-2008

The Case of a Firefox Bug!!!

Jerry Posted in Browsers, Computer and Internet, Geekiness, In My Readings, Linux & OpenSource, Science and Tech., Windows/Microsoft No Comments »

How cool can it get. On the very first day at office you get to do things that you just simple love doing?

The Case : A page is displayed with a certain width in IE. But is taking the whole width in Fx … :)

Sounds familiar ? They where about to tag it as an Fx bug. Wait a sec!!! That’s not a BUG in Fx. Its just the way Fx is handling things. Pop in some things i read at Joel’s blog - Martian Headsets. Voila!!! all agree that its not a bug… :). I’m happy, they are happy … :)

Here is my simple explanation :

Its all with the implementation difference of the two browsers.

In US you drive on the right side of the road. Hence all cars are left-hand drive.

Bring the same car to UK/India where we drive on the left side of the road, things seem to be a bit mixed up. You car is not buggy nor is the law in place. Cars are always designed to place the driver towards the center of the road. in UK it has to be the right side of the car, but in US it has to be the left side. There is no way out.The three seat setup inside an F1.

Why is there this problem? Coz all the countries doesnt have the same traffic rules. They have some basic guidelines in place and have the law built around it to match them. Simple!!!

To solve these confusions. Own a McLaren F1 car. It has a 3-seat setup, with the driver in the center. You never will have problem again. Just that you would have to be filthy rich .. :)