Tuesday, February 5, 2008

Linux shell scripting: PART 2

This shell example script mounts the cdrom drive:

File Name: readcd



#!/bin/bash
# CD-ROM Script
echo Setting up cd-rom..
mount /dev/scd0 /mnt/cdrom
echo ... Done.





This example shell script finds and mounts USB/PCMCIA flash drives. you can add this script to,
RedHat Linux 9 as part of the startup configuration scripts.

File Name: AutoM


#!/bin/bash
# Auto find & Mount drives script.
echo Setting up cd-rom...
mount /dev/scd0 /mnt/cdrom
echo ... Done.
mount -t msdos /dev/hde1 /mnt/flash1
mount -t ext2 /dev/hde1 /mnt/flash1
mount -t ext3 /dev/hde1 /mnt/flash1
mount -t msdos /dev/hdg1 /mnt/flash2
mount -t ext3 /dev/hdg1 /mnt/flash2
mount -t ext2 /dev/hdg1 /mnt/flash2
mount -t ext2 /dev/sda1 /mnt/usb1
mount -t ext3 /dev/sda1 /mnt/usb1
mount -t msdos /dev/sda1 /mnt/usb1
mount -t ext3 /dev/sdb1 /mnt/usb2
mount -t ext2 /dev/sdb1 /mnt/usb2
mount -t msdos /dev/sdb1 /mnt/usb2
mount





Script Set-up:
Open A new Shell and type in the next set of 5 commands:

cd /mnt/
sudo mkdir /usb1
sudo mkdir /usb2
sudo mkdir /flash2
sudo mkdir /flash1