Wednesday, April 18, 2007

FTP Automation using Shell script

I am going to give the code in shell script for ftp automation.

ftp -n servername/serverIP << FTP_AUTO
user giveusername givepassword

Any ftp command you can give here

bye
FTP_AUTO

Explanation:
1. -n is used to restrict the ftp from attempting auto login.
2. << here document concept applied here and hence the tag is FTP_AUTO
3. user is the ftp command
4. You can give any ftp command after the user command to do your job.
5.End the here document with the same tag FTP_AUTO

Monday, April 16, 2007

How to mount WIN partition in Linux?

Temporary Mounting: After the reboot of your system, you need to again execute the mount command to mount the win partition in Linux.

1.You need to create mount point(directory) for each win partition(drives) inside the /mnt directory.
eg: mkdir /mnt/winc (You can give any name instead of winc)

2. By using the mount command, we can now mount the windows partition
eg: mount -t vfat /dev/hda1 /mnt/winc (In linux, first partition is called as hda1)

3. Now get inside the /mnt/winc directory and check the files.You will be able to see your files from C drive.
eg: cd /mnt/winc

Permanent Mounting: To do the permanent mounting, you need to follow these steps below.

1.Create mount points (mkdir /mnt/winc)

2.Edit the /etc/fstab file using any text editor like vi and insert the mount point and file system details at the end of the file with the proper spacing as previous lines.
eg: /dev/hda1 /mnt/winc vfat

3. After the reboot of your system, you will be able to access all C drive files.

How to rename group of files?

I am giving a simple shell script, for renaming a group of files in the current directory.In the script, i have renamed all .jsk files to .txt files.

for filename in *.jsk
do
mv $filename `basename $filename jsk`txt
done

Explanation:
1.In the for statement, i am finding out all the .jsk extension files.
2.In the mv statement, i am using basename command to strip the jsk extension.