Mailing and Telneting with PERL

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.

icon smile Mailing and Telneting with PERL Drop in a line of you have more queries on the script. Always happy to help.

Single, Sex and Marriage

Of late, especially after i booked my flat, my folks are after me, pressurizing every bit inside me to get married. Well, thought you should know, i’ve been a bachelor and i had my share of heart breaks and breakings. After the last one, i just decided to settle with the drunk chicks at the pubs or rather get’em drunk. But how the hell am i supposed to know that my folks were having such plans for me. Trust me, its tough to be a single, good looking, smart dark bachelor down south (i love vanity). The nosy neighbors and relatives makes sure that the juice is sucked out of you. Damn you Suckers!!!

The hard part is, you don’t get to choose or say a word beyond telling yes/no to the girls that they parade in front of you. I consider myself lucky, some guys i *knew* never even had that.

Son! THIS IS YOUR BRIDE! Marry HER!

Yes dad!!!

I mean whats the whole pressure thing about? I’ve been a really well spoiled bachelor so far, waking up and sleeping with the timings of people half-way round the world, eating anything that i could lay my hands on – stale breads, half-cooked spicy chicken curry that cleans your food-track once a month, Domino’s pizzas that run for 2 days etc. etc.. Now i’m being even more responsible by booking a flat (i need to mention that it was again pressure from folks). Now that i have a place for myself, the next thing that i need to concentrate is my career, blogging, make some money etc etc. I’m not ready to be tied down.

What are the odds, that the girl they pick for you is not gonna make your life miserable? Dad’s got a comeback for that too, “At least both the families are there to help you out with that”. Then why cant i just find someone with whom i’m comfortable with? Facts to be laid straight, yes they did take care of you for a long time, but do they have to pick up your partner too.

Am i ready to take the responsibility? Hell no! May be i would like to get married, after i know that person a bit more. If not, then jumping into marriage is no different than having sex, with her and your parent’s consent!

As a closing note, the last conversation with my dad ended with him telling me this -

“As a bachelor, you live like a King and die like a Dog, Once married, you live like a Dog and die like a King”

No idea who put that in his head, but i sure did got it out. Even my mom was left gaping after that dialogue.

If you can’t beat them, Mock’em

Blog Response to – If you can’t beat them, learn Kannada

There can’t be more than a handful of north-indians actually putting an effort to learn the language of the southies. If they are made to swear in the native language, or if they are forced to learn the native language then its only because they have forced it on themselves. So whats the big deal in Delhiites and Punjabis learning the local language. That’s not something to be hailed as their broadmindedness. But rather the result of their indifference and prejudice towards the southern states and their culture.

Lola Kutty in one of the episodes of Channel [V] I.Q. popped the question – Where is Kerala? Most of the answers were – ‘Somewhere in Tamil Nadu’. Now, how bad can it get. Civilized folks giving such a reply! That itself speaks about the apathy towards ‘Madarasis’. Ask an average office goer from south, the difference between a Punjabi and a Bihari, they would be witty enough to point out our Railway Minister and our PM.

Hindi is our National Language and folks from south did make an effort in learning the language. But i’m sorry, if they have a thick Malayali or Tamilian accent or if they add a ‘da’ to the end of every known question to man. Its utterly ridiculous to make fun of a person if he/she has an accent. You’re not British, you too have got a bloody crisp ‘d’, as in doe, doe-saa accent for ‘dosa’.

No language is enforced on anyone. Be polite to the hard earning auto-drivers and tell’em that you don’t know Kannada and they will help you. Rather than using your ‘decent-enough’ knowledge of the native language to get in and out of fights.

Hey wait a sec, lets talk about the cream of the industry, the IT world. You are taught to co-ordinate and collaborate towards a common goal. So lets all start to converse in English or rather Hinglish or Manglish or Tanglish. Down south an accent is not a big deal and nobody brags about it.

Scene 1 : One fine day, you are with your ‘good-english’ speaking northie friend and happen to meet a friend from your place. You speak to your friend in your tongue and the good northie samaritan aloo-paratha asks if you could make it in a common language. You and your friend struggle with the oddity of having to speak in a mixture of English+Hindi, just to make the other friend feel comfortable and not to make him feel like the odd one out.

Scene 2 : One fine evening, you join your good northie friend for a cup of tea. In walks his friend, they take off in hindi and you try to put the message across, the same way he did. 2 min into the conversation, your friend says, ‘Hey, you got a thick tamilian accent, its doe-saa and not dosha“.

Scene 3 : All four happen to meet at the same time. Northies take off in hindi and rambles on. You say a single line in your mother-tongue, Objection Your Honour!, ‘What are you guys talking about? All we can make out is pada-pada-pada-pada-pada-pada!!!’ or even worse ‘What are you guys talking about? All we can make out is – idly vada idly vada idly vada’

Now why is there such a sick behavior. Its not that we don’t know your language. Trust me down south 80% of the people in cities that you happen to come to, know Hindi, to a level that they follow you even if you are a Bihari or a Delhiite. Even still they simply choose to ignore as they feel, you come down south and ridicule them for what they are.

Bangalore would have been a truly international city, if the people who landed here could have given a little consideration to the local culture and people and rather not treat them as trash.

(Cross-posted here)

Blogging Workshop at BIMTECH

logo BIMTECH Blogging Workshop at BIMTECHNever ever did i expect that something that i follow as a passion would get me a chance to conduct a session at one of the best business schools in north India.

Last week-end, i flew to Delhi and on Saturday i was at BIMTECH, Greater Noida, for a session on blogging and the monetary benefits of blogging. The E-Cell of BIMTECH had contacted Mutiny for help and i took the offer.

The session was planned at 6p.m.. You really have to appreciate the guys who study at b-schools, a session at 6p.m. was nothing for them. Other colleges too were invited for the workshop and there were indeed people present at that time of the evening on a Saturday evening.

The session kicked off after a brief intro about the speaker, ahhmmmm that’s me icon smile Blogging Workshop at BIMTECH , and about Mutiny and of collage 300x187 Blogging Workshop at BIMTECHcourse about my friend Mayank (yes its the StudioWordpress guy!!! – http://mayankgupta.com or http://mayank.info ). Mayank was supposed to be on time and help me out with the session, but he was caught up with an emergency Snooker game-session. Well he did turn up to save me for the last 30min icon smile Blogging Workshop at BIMTECH .

I started off at the same grounds from where i started the blogging session at Wipro. Telling them everything that i knew about blogging, etiquette, etc etc. But there was a flaw. Most of the people who were there didn’t know how to start a blog. By ‘start a blog’ i mean they didn’t know even how to get a blog at blogger. The lesson – get to know the people and the requirements before we start.

So STOP!!! Get back to the basics. Took them through the live demo of setting up a blog in Blogger. So when all was set, and everyone was on the same page, we were back to where we stopped.

Mayank was just in time as i was getting warmed up with the business side of blogging. Talked about some of the ways that i knew about making money out of blogging. Though i have to mention that i’m too lazy for a blogger that i don’t earn as much as others do, out of blogging.

The idea of a community blog was something new to them. The facts on how Mutiny has grown and maintains itself interested them.

After that it was Mayank’s turn to help everyone with the things that he knows. The way he earns his living was interesting to listen to and i’m quite sure that it would have opened up some idea for those who were listening.

The fact that interested me a lot was the volume of idea that people had for blogging. They all wanted to blog for so many reasons and they just wanted to know how.

Put together the session was one that’s one of the most memorable. I’m taking back some very valuable learnings and some ideas with me.

More pics here

BloggingWordshopAtBIMTECH Blogging Workshop at BIMTECH
Blogging Wordshop at BIMTECH

If any BIMTECH guys are reading this, i would like you to give me you feedbacks and comments too .. icon smile Blogging Workshop at BIMTECH

(Cross-posted here)