Archive for February, 2009
How to open a popup window upon page load
Feb 28th
In JavaScript, window.open method can be used to open link in a new window. This method can be used to open a new window when a page is opened. However this method of opening a pop-up window will be blocked by recent browsers as part of their pop-up advertisement blocking feature.
Place the following code in your HTML file.
<script type="text/javascript"><!--
window.open('http://techpulp.com');
//--></script>
How to execute a command with in VI
Feb 28th
You can use “:!” sequence followed by the command string in the command mode of VI.The following steps explain the procedure.
Type Esc to enter in to VI command mode
Type colon (:) and (!) followed by actual command string.
For example, if you want to run “ls” command, you would need to type “:!ls” in VI.
Auto SSH login using ‘expect’ tool
Feb 28th
The “expect” tool can be used to achieve auto login for interactive commands like telnet, ftp, ssh and others. Automatic login is useful to avoid unnecessary delays in work and also useful in automation. However this method requires your password to be stored in the script in plain text. But you can set the file permissions so that you only can access it.
Using “expect” tool, we can spawn a command and expect certain messages from server and send user-defined strings to automate interactive prompts. So the script will be typically specific to a server because other server may prompt for More >
How to encrypt a partition in Linux using cryptsetup tool
Feb 26th
Recent Linux distributions include cryptsetup-luks package installed by default. This package makes disk encryption pretty easy in Linux. You can either choose to encrypt a partition on the disk or create encrypted file system with in a file using loop-back device. This article outlines the basic usage of cryptsetup tool to set up encryption of a disk partition.
If you don’t have cryptsetup-luks package installed in Fedora Linux you can use “yum” to install it. For more details read this article and look for xinetd package installation.
Initializing Disk Partition for EncryptionThis procedure is required only once to initialize a disk partition More >
Bash script to replace a word or a string in multiple files at once
Feb 21st
There are multiple ways of replacing a word or a string with another in a stream of input. Here, in this article, we use “sed” command. While the “sed” command operates on one file at a time, the bash script takes care of iterating it through multiple files and making backups of original files. Run the following script with no arguments to view help.
#!/bin/bash
usage() {
echo Usage: $0 str-from str-to files
echo e.g: $0 "this string" "that ring" file1.txt file2.txt file3.txt
exit 1
}
if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" More > How to set up a CVS server in Linux
Feb 18th
Repository Initialization
First create a directory to be used as CVS repository and initialize it as shown below.
[root@techpulp ~]# mkdir /cvsroot [root@techpulp ~]# chmod 1777 /cvsroot
Initialize the repository for the first time
[root@techpulp ~]# cvs -d /cvsroot initInstall inetd or xinetd
The CVS server requires either legacy “inetd” or latest “xinetd” package be installed in the system. If you don’t know how to find it, look for the presence of “/etc/inetd.conf” file for “inetd” package and look for the presence of “/etc/xinetd.d” directory for “xinetd” package. If none of them is present, you should install “xinetd” package. You can install a More >
Concurrent Version System (CVS) Quick Guide
Feb 18th
CVS is a heavily used source control system both in open source projects and commercial projects. This article explains frequently used commands by a developer.
Set the command-line environmentFirstly, before using cvs command, the CVSROOT environment variable should be set to point to CVS server. This command can be placed in ~/.bashrc to make it as default environment.
[neo@techpulp ~]# export CVSROOT=:pserver:neo@cvs.techpulp.com:/cvsroot
In the above command, cvs.techpulp.com is the CVS server, neo is the user name on the CVS server and /cvsroot is the base of the CVS repository in the server.
It is not necessary that CVS must be used only with remote CVS server. If you More >
Bash script to delete blank lines from a file
Feb 14th
There are multiple ways of deleting blank lines from a file. This article tells how to use “grep” command to achieve the objective. The “grep” command provides an option “-v” to invert the matching. That means grep finds the lines that are not matching the pattern specified. The matching pattern is a simple regular expression to match all blank lines i.e “^$“. The “^” character means beginning of a line and “$” means end of a line. The pattern matches all blank lines as there are no characters between “^” and “$” characters.
Here is the sample file “sample.txt” that contains More >


Recent Comments