w w w . T H E B I T S . c o . u k


How Do I Create My First Shell Script?

Home Contents Previous Next

A script at its very simplest, is just a text file that contains a series of Linux shell commands. By then making the text file executable you have yourself a script.

The following script when executed, will: mount your CD-ROM; change the directory to '/mnt/cdrom' and list the contents of the directory.

- 1 -

Log-on as 'root'.

- 2 -

Enter :

pico cdrom

- 3 -

Enter the following in Pico :


mount -t iso9660 /dev/hdb /mnt/cdrom cd /mnt/cdrom ls > less

...and press <Ctrl>+<O>, then <Enter> to save the file, then press <Ctrl>+<X> to exit Pico.

Note

Remember to change the 'hdb', if this is not how your CD-ROM is setup. For more details check out 'And What About My CD-ROM?'.

- 4 -

Enter the following to make the file executable :

chmod 744 cdrom

- 5 -

To run the script, first insert a CD-ROM and then enter :

. cdrom

By Laurence Hunter laurence@thebits.co.uk

Home Contents Previous Next

Download Latest Manual

www.THEBITS.co.uk - updated daily...