Opening a bank account …

I had thought it an absurd requirement to have a reference of someone who opened their account in the same branch in which you wish to open a new bank account. This guy left me under that misapprehension. It was not until I walked into the branch office in my area the other afternoon to request to open an account that I was told that a reference of anyone who opened their account in any branch of the bank will do, but that the request will be processed more quickly if it is from the same branch.

The guy at the branch office I visited asked me to bring some requisite pieces of documents on my next visit, so that he can start filling my form and processing it. Only, I seem to have forgotten what he asked.  That means, another extra visit to the office tomorrow (perhaps).

Pertaining to Cricket and everything around it.

A friend and I had a brief conversation online about the on-going debate over the third test match between Pakistan and England which came to a controversial stop. Here’s the coversation. Enjoy. ;-)

Ayaz: What are you doing? Watching porn?
Aqua Hill: no. just reading about inzimam and the match contreversy
Aqua Hill: what are you doing? watching porn?
Ayaz: no.
Ayaz: i’m writing an e-mail to boss reporting the details of the scripts i have developed over the past couple of weeks.
Ayaz: so, what’s the controversy about?
Ayaz: are pakistanis really innocent?
Aqua Hill: pakistan should have left the field as soon as that asshole gave a 5 run penalty
Aqua Hill: than shahriyar khan lied by saying that the pakis “Were” gonna come out after tea, but a little later as in protest
Aqua Hill: to me thats a lousy alibi
Ayaz: i don’t see a need to tamper with the ball if i’m already winning the game by a long shot, unless of course, tampering with the ball is how i got into that position of immient vicotry.
Aqua Hill: but the asshole was too harsh he thought we was god
Aqua Hill: that too is a point
Aqua Hill: but its proved
Aqua Hill: there was no tampering and the ball change and the 5 run penalty was wrong the debate is over what happened after tea
Ayaz: oh, so the debate has moved. i didn’t know that.
Aqua Hill: but i guess pakistan will makeup the loss by beating them in the one dayers
Ayaz: so, pakistanis have been declared losers.
Ayaz: although not cheaters.
Aqua Hill: yeah
Aqua Hill: my opinion is that pakistan should have won the match first, then given hell to the ICC in the onedayers by not playing under the asshole
Aqua Hill: well
Ayaz: our players aren’t exactly half as clever, you know.
Ayaz: and sharp
Ayaz: if they were, i guess, they wouldn’t have opted for a career in cricket and would have instead gone to take college after passing matric.
Aqua Hill: what about the Chariman, manager and the coach?? anyway…. i am packing up i have to travel in khi busses hove to mentally prepare my self
Aqua Hill: bye
Ayaz: travel safely. bye.

Dialog: Using Dialog boxes to interact with users on a Linux console.

You can’t throw in a GUI for an application that will be run on an enviornment without X. Does that mean you’re left to live with bland command-line prompts for interaction? Think again.

Ever done a text-based install of a Linux distribution? If yes, then I bet you haven’t missed out on those colourful boxes, pitched in combinations of red and blue or yellow and blue, requesting you to type in input and displaying output in return. If you have ever installed Slackware, any of the BSDs, or Debian, I am sure you can’t have overlooked those boxes. What are those? Don’t they look cool? Wouldn’t you want to have one to handle interactions with the enviornment on your command-line application(s)? If you’re anything like me who writes only applications which run from the console, sure as hell you do. I’ve got one word for you: dialog.

Yes! Dialog! Dialog is a program you can find on almost any Linux distribution. It is a program that displays colourful dialog boxes for interaction with the user. It can display information boxes, which contain nothing but text to display on the screen inside a colourful box, menu bars, input boxes, check boxes, etc. You name it, dialog has it.

The manpage documents dialog(1) in detail, being the all-in-one manual to understand how to use dialog and start using it. I see no point in re-hashing the contents of the manpage in my own words. But, yes, I think a simple BASH script to make use of the dialog utility to create a couple of dialogs to take input from user would be sufficient to get the curious onlooker started.

#!/bin/bash

dialog --backtitle "Dialog Test Example" --title "Network Settings"
--no-shadow --menu "DHCP or Manual" 0 0 0 "dhcp" "Enable DHCP"
"manual" "Manual Ip Setting" 2> /tmp/output.file

dialog --backtitle "Dialog Test Example" --title "IP Settings"
--no-shadow --inputbox "EnterIP:" 0 0 "192.168.1.10" 2> /tmp/output.file

# End

Execute the script and be mesmerised by the magic of dialog. By the way, do take a look at the file /tmp/output.file when you’re done running this simple script. ;-)

Independence Day!

Back when we moved into this suburb nearly 17 years ago, I remember clearly how barren the place was. Over time, empty houses started getting occupied, and the whole suburb lit up with life. I made friends with a dozen kids in the neighbourhood. I used to play with them, from anything from cricket to hockey to basketball. During the rain season, armed with toy guns which made funny sounds when fired, we enjoyed playing what we called “Robbers and Police”. An empty underground water tank in the porch of a deserted, dilapidated house formed our headquarters. It was dangerous what we did, but no-one I remember ever gave a thought to it. And I don’t even remember any of our parents admonishing us for jumping into dark, deep tanks, and sitting there, conducting covert meetings. It was all fun. Great fun.

Then there were the preparations for celebrating the Independence Day that each one of us looked forward to eagerly. I remember those vividly, as if it happened only yesterday. We would gather in the lounge of an empty house, buy lots of flags, threads, glue and paper flags, and whatnot. Within few days, the whole street would get adorned in hues of white and green. There would be paper flags, flapping and making the sound stiff paper makes when it strikes against a wall, all over the walls, from house to house. Large, thickly green and white flags would be seen flapping in the wind, wound with rope to the poles on each house. The grills on top of the perimeter walls on the houses would additionally be lit up by small colourful lights. At night, the whole street would look different: It would look colorful, lively, oozing with the spirit of celebrating the Independence Day. I remember all of it like it was just yesterday I walked out of such a breathtaking view.

Today is Pakistan’s 59th Independence Day. As I get out of my house, a strange feeling of sadness grips me. I see no flags. I see no lights. I see nothing that suggests today is a special day. For most people, today is just another holiday: A day to rest and sleep till late afternoon on. I swing my head, taking a deep, thorough look at the street that once used to be adorned as delicately as a bride. It looks so barren. Cars lined on either sides, the street looks deserted. There isn’t a single person in sight. Everyone’s sleeping. There isn’t a single flag flapping in the wind. I am not even sure the wind longs for the by-gone days. I am not even sure people realise the significance of the Independence Day. Granted, none of us is a kid anymore. Each one of us has grown up. Most have moved elsewhere, and those who still live here, are busy in their own schedules. But who said there aren’t any new kids on the street. There are. Many. But, these kids are different. Unlike us when we were their age, they come out only to play and then go back inside. The thrill of celebrating a special day such as today fails to enthuse them. To them, like to their parents, today is another holiday, to sleep, watch
TV, and play on. What a shame!

Happy Independence Day!

rsync: How to efficiently mirror websites, directories, and filesystems.

From the manpage of rsync(1):

rsync is a program that behaves in much the same way that rcp does, but has many more options and uses the rsync remote-update protocol to greatly speed up file transfers when the destination file is being updated.The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network connection, using an efficient checksum-search algorithm described in the technical report that accompanies this package.

rsync is not any file transfer program. It is an intelligent file transfer program, used widely to mirror websites, directories and entire filesystems. What makes rsync superior to other file transfer programs, like rcp and scp, is its ability to efficiently compare the differences between two files and to copy only if either has been updated.

At work, I do all my development inside a Virtual Machine running Slackware. Any code I write at work and, more importantly, as part of work, I keep in a separate directory cleverly named “work” inside the /home directory. With no back-up server yet in place, and fearing the day the host OS would crash or the Virtual Machine image would get corrupt, I brought my home laptop at work to mirror, at least, the work directory. I used EverythingLinux.org’s simple-to-follow tutorial to set up rsync on the Virtual Machine image, and call the rsync client from the laptop to back-up the work directory.

While I strongly suggest that both the manpage and the tutorial referenced be read thoroughly, I will, nonetheless, list down instructions to quickly get rsync up and transferring files.

The enviornment I’m using is laid out like this: I wish to make a copy of my work directory, /home/work/, on a Slackware box, bound to the IP 192.168.1.10, over to my laptop, also running Slackware, and bound to 192.168.1.247. rsync is installed on both systems. First, I need to set up rsync daemon on 192.168.1.10 by creating rsyncd.conf, the file from which the rsync daemon reads various configuration settings. The manpage of rsyncd.conf(5) thoroughly documents all configuration variables, parameters, directives, and also contains useful examples. I set up /etc/rsyncd.conf to mirror the following config:

motd file = /etc/rsyncd motd
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock

[work]
       path = /home/work
       comment = Code repository from Work
       uid = ayaz
       gid = ayaz
       read only = yes
       list = yes
       auth users = ayaz
       secrets file = /etc/rsyncd.scrt

A brief explanation is in order. “path” points to the directory to be mirrored. “uid” and “gid” are the user and group IDs, respectively, under which file transfers will take place. I don’t want /home/work to be altered by any client through rsync, so I have set it to be read only. I have also set “ayaz” to act as the user allowed to connect to the rsync server. A user:pass pair for the allowed user is put in plain-text in the “secrets file”. If anonymous rsync is desired, then the “auth users” and, consequently, “secrets file” directives should be taken off.

These are a small subset of the options rsyncd supports. The manpage, rsyncd.conf(5), documents every aspect and option of rsyncd in detail. Finally, to execute the rsync daemon, I call rsync with the “–daemon” flag. rsync’s daemon runs in the background, on port 873 (default).

Now, over to the client side, the laptop. I create a directory, /home/work, and modify its user and group ownership to match the “uid” and “gid” set in rsync daemon’s config file. Running the rsync client is simple. Before running it, I’d suggest a thorough read of rsync’s manpage, again, rsync(1), to understand the various switches it supports and the different ways in which it can be used.

I call rsync like this:

$ rsync -avrzogtp –rsh=ssh –exclude “*.~” –exclude “linux/” 192.168.1.10:/home/work/ /home/work/
Here’s a quick description of the various switches used. “-a” does the archiving. “-v” turns on verbosity in output. “-r” tells rsync to get into recursive mode while traversing directories. “-z” enables compression. “-p”, “-o”, and “-g” preserve, in that order, the permissions, owner and group information of files and directories to be copied. “-t” preserves the file and directory timestamps. I don’t wish to send data in plain on the wire, so, I order rsync to use “ssh” instead to tunnel data. Like tar, rsync supports –exclude switch. I tell it to exclude any files with a trailing “~” character in their names — Vim rather stubbornly does tha –, and to exclude the entire “linux/” directory. Finally, I specify the source host and source directory, followed by the local directory where the data should be moved.

And that’s it. The first time around, I was nervous running rsync. Just to be sure it wasn’t going to do anything crappy on my laptop’s filesystem (which shamefully itself isn’t backed-up yet), I ran rsync on my laptop with the “-n” switch. It does a dry-run only, in that it only generates a harmless list of files it will copy from the source system and quits. Again, read the manpage for many more options.