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. No Comments »

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


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


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 .. :)


13th

Jun-2008

Should You Download on June 17th?

Jerry Posted in Browsers, Computer and Internet, Freedom, Fun, Geekiness, IT Industry, Media, Review, Science and Tech. 2 Comments »

Download Day 2008

Bruce Almighty, the movie starts of with Bruce, a TV Reporter, asking an old woman, who owns a Patisserie -

“So tell us mama, why make Buffalo’s biggest cookie?”

“Well, man from the health department say he find rat pellet in store. I say no is big chocolate chip. So we close store down, clean up, and make big cookie for to bring back customers”

I see no difference in that and this -

Come June 17th and there is going to be this multitude of people from around the world, who are just going to download Mozilla Firefox v 3.0. Why? Just because they are attempting to set a world record on the maximum downloads of a single software in 24hrs. What a creative reason to set a record?

So what is so great about this download spree that the guys at Mozilla are hyping about? Does the people who download it get a free mug every day for the rest of their life? Or is it something like the spam mail, ‘If you dont download Fx in the next 24 hours, your system will be infected by a deadly strain of I love Fx virus!!!‘.Its all for the sake of a record and damn publicity!!!

I use Fx and its not that i wont be using 3.0. Its a great browser and i’m sure just like the way it has changed my browsing experience, it has done for millions. The plugin support is amazing. To download it on that particular day is a personal choice. I agree. But just because you like a piece of software doesnt mean that you need to join a drive just to download it.

The way i see it, is as a smart marketing strategy. If they are really as good at the cookie that they sold, then why do they need such a drive. If a product is good, people who use it becomes the biggest marketers for it. They spread the word and the number of people who are using it expands. Why does Fx3.0 need such a drive? Fx2.0 was brought in with a big bang. But it suffered as it began to eat up memory. A normal session of Fx2.0 with 3-4 tabs open is enough to consume 10s of MB of RAM.

Memory is cheap, i agree. But that doesn’t mean that an application can take up as much memory as it desires. I’m not too good at judging as to what is wrong. But can say that the memory management was poor in Fx2.0. At the time when Fx2.0 was released people with normal browsing habits found that the systems slogged badly, Windows and Linux alike. They opted to move out. Intermittent releases didn’t solve the version either. How annoying is it when you get a new version to download every couple of weeks?

Fx3.0 is hailed to be faster and secure. The Release Candidates a.k.a Beta are better than Fx2.0.

… As several of the linked posts below accurately reported, we’ve decided to add one more beta in order to make further improvements in the areas of polish, performance, memory, and overall quality … [from Mozilla: For the Record]

The question remains, are they still the same old Patisserie reopen by making a big cookie, after the Health Dpt. shut’em down?


11th

Jun-2008

To CANCEL a Connection…

Jerry Posted in Advice, Computer and Internet, Nation, Rubbish, Town & City Life, stupidity 3 Comments »

Reliance CommunicationsTake my advice.

If u don’t have a Reliance connection phone/datacard or anything similar don’t take it.

And if by chance and you had to take it. Don’t think of Canceling it!!!

Why? Hear my story :

It was during Barcamp Banaglore 5, that i had discontinued the Tata Indicom Broadband connection as their service was shity. YES damn SHIT!!!.

My thoughts went like this - i have a laptop so why don’t i go for mobility. Let me take the the Reliance NetConnect connection. The data card looks good and works out of USB plus their tariff plan is also good.Finally at an unfortunate moment i took that connection.

Is there a word in the dictionary that describes worse than ’shity’? Even ‘ultra-f***king-shit-able’ doesn’t properly suffice. It disconnects if i try to check Gmail and connect to GTalk at the same time.

So i decided, after 2 months, enough is enough - cancel the connection. Filled all the forms, submitted the application, paid the outstanding amount and answered two rounds of dumb feedback calls.

Q : Sir, why did you cancel the connection?

A : The Service is BAD.

Q : Why sir?

A : Its Shitty!!! (how the hell am i supposed to know why its BAD. You should be knowing it)

When i thought all was done, in comes a bill at my door step, the next month. Dialed the customer care, told them the scenario. Thought it could be a genuine mistake. WRONG!!! In comes another bill the next month and the next and this month too.

After that a wave of calls in  Hindi, Kannada and English asking me to pay the bill. Still the woes continue and the bill amount keeps on adding every month :(

cm_message To CANCEL a Connection...

Nothing helps. Complaints at customer care doesn’t help, blasting them for calling me doesn’t help, pleading doesn’t help….

PLEASE DON’T EVER TAKE A RELIANCE CONNECTION

Yes!! Mr. Anil you’re having a very sustainable and rewarding relation with ME.