UNIX/Linux: Copy files from different sources to different destinations

I faced a situation exactly similar to one of my earlier posts. Only difference was that I had to use shell script this time. :)

This time, it was achieved using array simulation. Though not a very elegant way as few might think of but I found it cool. :) So here we go.

I’ll copy the source and destination path in a file named data. As you can see below, each source and its corresponding destination is separated with a special character ‘=’. You can, however, use any special character of your choice as a delimiter.

Ant: Copy files from different sources to different destinations

I had a situation where I wanted to copy few files present in different directories to different destinations. Instead of directly using ‘copy’ task in the main xml file, I was looking for a better way. I wanted to store all my source and destination in a file, read it, and perform the copy operation. I wanted to keep my main xml file clean.

Forfiles - Windows utility for batch processing

Few days back, I had a situation where certain files and folders had to be deleted after a specified interval of time. In UNIX, we have ‘find’ command, which could have performed this task neatly but this particular task was to be done on Windows machine. So I started looking out for some utility, and bumped on 'Forfiles'. It’s a powerful utility which does exactly what I wanted.

Contingency measure against recession

I had this gut feeling that this skill of mine will help me in the long run. Recession just proved it!

My workplace

14/5 mastermind Cockroacha a.k.a Roacha killed

Cockroacha a.k.a Roacha, the mastermind behind many attacks carried out on innocent salads, vada-paav, sambar etc. was killed (at Aarav society, Pune) minutes before in a devastating strike made by the SWAT team led by Gaurav. Gaurav made sure that the best were in his team. Chetan & Kapil were his obvious choice as they had conducted similar operations in the past successfully.

                                         Roacha taking his last breath... 

MySQL ERROR 1046 (3D000): No database selected

While I was trying to view the tables in a given database, I encountered the following error:

MySQL Error Message: ERROR 1046 (3D000): No database selected

What happens is that when you connect to a MySQL server, it doesn't choose a database for you unless you explicitly specify it.

Pastebin - share code snippets for public/private viewing

Many a times, we visit forums searching for answers to our problems/issues. Sometimes, we do not find what we are looking for or we do not know where/how to look for. In such cases, we post our queries on forums. Now if the query involves considerable amount of code snippets, then in that case, we can make use of applications called pastebin.

Plink - command line connection tool

I was looking for some tool that can run commands on remote machines non-interactively. It had to be an open-source tool, and a tool that can be easily configured. Plink was the one. It’s from the PuTTY family.

To use Plink, make sure that plink.exe is in your path or your current directory. To add Plink to your PATH environment variable, open the Windows command prompt, and run the following command:
set PATH=C:\path\to\plink.exe\directory;%PATH% 

For example, if plink.exe is in C:\temp, then type:
set PATH=C:\temp;%PATH%

To check whether Plink is working fine, just type Plink on the command prompt. You should see a list of options available for Plink as stated below: 

OpenSSH installation on Windows

We frequently require communication between two machines, and we also require that the communication be secure. In such cases, we cannot use telnet, rlogin, rcp etc. because they are not secure: all communication happens in clear text, and no authentication takes place. That’s where SSH comes into picture. OpenSSH provides end-to-end encrypted replacement of applications such as telnet, rlogin, and ftp. It also makes sure that you are actually talking to the machine that you think you are. Well, that was a very short note about why we should use SSH for secure communication. Now let’s move on to OpenSSH installation part.

Transfer large binary files using xdelta (binary diff tool)

As part of build & release activity, I often have to copy war file from local machine to remote machine for deployment. Copying a war file (160 MB approx.) to remote machine is quite a time-consuming activity considering that it takes close to an hour or so depending on the network. Thanks to this frustrating case which prompted me to look for a solution.