I ran across a cached Google entry for a good collection of awk one liners by Eric Pemant. Since I thought the original site was down, I decided to host it on my domain at https://kudithipudi.org/misc/awk_one_liners.txt. But I did some digging and looks like Eric has his own site now and hosts a lot more resources related to awk at http://www.pement.org/awk.htm. Thx for the great collection Eric..
HOW TO : Find which interface a particular IP address is configured on
There are a ton of scripts to find how many IP addresses  are configured on a system, but I could not find one, whic would show me which particular network interface an IP address was configured on. Here is a one liner, that will give you this information in Linux
/sbin/ifconfig | grep -B1 10.10.10.10 | awk '{if (NR==1) print $1}'
The same script can be changes a bit to support other operating systems too. Essentially, I am doing a grep (search) of the output of ifconfig, which shows all the network information on the system for a particular IP. At the same time, I am using the -B1 option, which will show the line above the matching line. Finally, I am piping this to awk and printing the first row in the first column.
Travelocity down due to power outage..
Looks like Travelocity was down early today due to a power outage. Here is a screenshot of the site, right after they came up

According to Pingdom, the site was down for ~1 hour and 29 minutes. If they did come up at an alternate site, I personally think that is a pretty good response time. Running a high transaction web site (and one that is as complicated as Travelocity) is no easy feat and when you throw DR into the mix, it gets pretty nasty. The site is primarily hosted out of the EDS/Sabre/Travelocity datacenter in Tulsa, Okhlahoma.
2009 Webware winners
If you are an Internet junkie like me, here is a list of the 2009 Webware winners.
 http://www.cnet.com/html/ww/100/2009/winners.html?tag=newsLeadStoriesArea.1 .
You will recognize a lot of the names and might also discover some new cool sites.
HOW TO : Pass environment variables when using sudo
Say you need to sudo as a particular user and run a command and at the same time you need to pass an environmental variable to the command, you can do it by passing the command in doublequotes.
For example, I want to start Oracle while I am logged in as another user (vinay), I can start the database using dbstart by issues
"sudo su - oracle -c "dbstart /$ORACLE_HOME"
$ORACLE_HOME is an environmental variable listed under user oracle’s environment.
Needless to say, you need to ensure that you have sudo configured to allow your userID to su to oracle.
HOW TO : Block outbound e-mails in Postfix
I ran into a challenge at work, where we had to allow e-mail delivery for certain domains, but block all other domains. But at the same time, we had to ensure that the clients sending e-mails did not get a delivery error. We were using Postfix as the MTA running on Redhat Linux. Here’s how I resolved it
- Edit the main.cf file (the default location is in /etc/postfix) and add “transport_maps = hash:/etc/postfix/transport” (without the quotes) to the file.
- Create a file named “transport” in /etc/postfix, if it doesn’t exist
- Add the following at the end of the transport file
DOMAIN1 :
DOMAIN2 :
* discard:
- Run “postmap /etc/transport” to create a hash of the transport file
- Run “service postfix restart” to restart the postfix service
This configuraiton will ensure that all e-mails address to DOMAIN1 and DOMAIN2 are delivered normally, but the rest of the e-mails are silently discarded.
Note : Ensure that you follow the syntax for where to place the : verbatim.
Google knows that I am Indian..
I logged into Gmail today and noticed this small icon on the left hand side of the rich editing option, a small icon showing the letter “a” in my native tounge (Telugu).. Me being the curious kind, clicked on it and found out that I can now compose e-mails in multiple Indian languages (Hindi, Tamil, Kannada, Telugu & Malyalam) by typing in English. Something that Google calls “transliteration“. Here are some screenshots of me using the feature
Â

Screenshot of Gmail showing multiple language options..
Â

Screenshot of Telugu in Gmail
Pretty cool.. but scary too 🙂 that Google guessed I am Indian.
HOW TO : Redirect default home page on Jboss
If you want to redirect the default home page on Jboss (which has links to the Jboss site and also the JMX Console), you can do it by editing the index.html file in
$JBOSS_HOME/server/$INSTANCE/deploy/jboss-web.deployer/ROOT.war.
The $INSTANCE is the mode you are running Jboss in (default, all, messaging etc).
HOW TO : More examples of grep
For my reference.. good article about command line usage of grep . http://arstechnica.com/open-source/news/2009/05/command-line-made-easy-five-simple-recipes-for-grep.ars . Older how to articles on my site related to this topic are here and here.
HOW TO : Setup SOCKS proxy using SSH/Putty and configure Pidgin to use SOCKS proxy
I ran into a challenge recently, when I tried to connect to my IM services (Yahoo, MSN, AOL, GTalk) using Pidgin in a secured network. For some reason, the network administrator thought that he/she should make life hell for people trying to log into IM. I will have a whole new rant about companies trying to lock down networks thinking they are making the employees productive..
Here’s what I did to connect to my IM services.
- Configure Putty/SSH to act as a SOCKS proxy.
- Most people might not be aware, but a typical SSH client can act as a SOCKS proxy. So I decided to leverage this functionality.
- You will need access to a SSH server and Putty (Opensource Windows SSH client)
- Launch Putty
- Setup a new server connection profile. I used FREE_MY_IP as the profile name in this screen shot, but you can name it anything you want

-
- Expand the SSH option in the left column and click on Tunnels
- Choose any port higher than 1024 as source port (unless you are running some kind of server software on your workstation, it is safe to use any port above 8000) and enter the SSH server in the Destination field. Then choose the “Dynamic” option and click on Add.. the screen shot below shows the options I used

- The tunnel will show up as below

- Click on Open and establish the SSH tunnel
- Configure Pidgin (open source IM client) to use the SOCKS proxy
- Launch Pidgin
- Click on Tools -> Preferences in the menu
- Click on the network tab
- Choose SOCKS4 as the proxy type and enter localhost in the host field. In the port field enter the port you selected when setting up the tunnel in Putty.

- Connect to your IM services.. chat away and be unproductive 🙂
