My 2 paisas

Posts Tagged ‘bash

It is sad that I have found this solution after so many days. It is more sad that I never tried to look for this solution earlier. I must have found it atleast 3 months ago. Anyways now that I have found it, let me tell you what exactly I want to do and how the simple script helps me do it.

I have been playing with qmail and qpsmtpd from last 3-4 months. Now to test my set-up, I used to telnet to the port and then used to enter different telnet commands and used to watch the logs simultaneously to get errors.
Now everytime I used to enter the commands manually and that too I couldnt just go to history and execute it as telnet does not support storing commands in history.
Anyway finally today I got fed up of it and I thought let me see if there is a solution so that I dont have to enter commands manually. I didnt expect a solution. But when I searched for it, I found that it was so easy to do it. You just need to execute the following command.
./ | telnet

and the contents of is given below:
echo open $host $port
sleep 10
echo helo
sleep 10
echo mail from:test2@domain
sleep 10
echo rcpt to:test3@domain
sleep 50
echo data
sleep 10
echo checking
echo .
sleep 10
echo quit

You can customize the script to anything that will make your life easier with telnet. I found this solution here,

Tags: ,

Courtesy to

If you have used UNIX for a while, you will know that there are many commands available and that some of them have very cryptic names and/or can be invoked with a truckload of options and arguments. So, it would be nice to have a feature allowing you to rename these commands or type something simple instead of a list of options. Bash provides such a feature : the alias .
Aliasses can be defined on the command line, in .bash_profile, or in .bashrc, using this form :

alias name=command

This means that name is an alias for command. Whenever name is typed as a command, Bash will substitute command in its place. Note that there are no spaces on either side of the equal sign. Quotes around command are necessary if the string being aliassed consists of more than one word. A few examples :

  • alias ls=’ls -aF –color=always’
  • alias ll=’ls -l’
  • alias search=grep
  • alias mcd=’mount /mnt/cdrom’
  • alias ucd=’umount /mnt/cdrom’
  • alias mc=’mc -c’
  • alias ..=’cd ..’
  • alias …=’cd ../..’

The first example ensures that ls always uses color if available, that dotfiles are listed as well,that directories are marked with a / and executables with a *. To make ls do the same on FreeBSD, the alias would become :

  • alias ls=’/bin/ls -aFG’

To see what aliasses are currently active, simply type alias at the command prompt and all active aliasses will be listed. To “disable” an alias type unalias followed by the alias name.

One more important thing. After you have added alias in .bashrc, you need to inform your system about the changes and hence execute the following command:

  • source .bashrc
Tags: ,

Links that I liked to save

Blog Stats

  • 45,193 hits