Archive for the ‘shell’ Category
Posted July 4, 2010on:
I had used wget and downloaded all the java videos from the java tutorial site( and also all the other files on the website). There were around 20 of them. The problem was that the lectures were each present in a separate folder and I had to traverse to each of them to watch them. So I thought of writing a script which would search the main directory recursively for the lectures and then copy it in a specific folder. Luckily in my case each of the lecture were named differently and hence I didnt have to rename them and there were no issues of file name getting clashed. Below is my shell program:
list=$`find . -type f | grep ".mp4"`
cp $list ./lectures
This would search all the files which had .mp4 in their name and copy them into the folder lectures.
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.
./smtp.sh | telnet
and the contents of smtp.sh is given below:
echo open $host $port
echo helo deeproot.co.in
echo mail from:test2@domain
echo rcpt to:test3@domain
You can customize the script to anything that will make your life easier with telnet. I found this solution here, http://www.linuxforums.org/forum/linux-programming-scripting/92466-telnet-script.html