OpenSource For You

A Quick Look at Programmin­g with Shell Scripts

The power of scripting lies in the fact that you get to program with commands you already know, from various computer languages. Scripting provides a means to substitute really complicate­d and convoluted commands and if there is something repetitive, then

-

Imagine that you are doing some important task on your computer system and, suddenly, you get a black screen with something being automatica­lly typed on it. I am sure many of us have experience­d such system reboots that take place on their own due to some hardware or software issues. When this happens, our pulse rate shoots up, and we hope and pray that the task that was being performed has been saved, or else, everything will have to be started afresh.

Have we ever given a thought to how all this happens on its own? Well, it’s shell scripting that drives such processes automatica­lly. A newbie in the computer programmin­g arena generally gets anxious just seeing the black screen on the computer, assuming the programmin­g involved is quite difficult.

In shell scripts, the term ‘shell’ defines the interface between the user and the different services of an operating system such as Linux, UNIX, Windows (to some extent) or Mac. Apart from the shell, the kernel is the other main component of an operating system. It’s the kernel that makes the communicat­ion between the hardware and software possible. The interface can be created by a shell through different command line interfaces (CLI) or in a graphical manner (using the GUI). A shell takes input from us in the form of commands, processes it and then gives an output. It can be accessed by a terminal, which runs it. Whenever we run the terminal, the shell actually issues a command prompt, where we can type our own input, which is then executed when we hit the Enter key. The output is thereafter displayed on the terminal. The shell basically wraps around the delicate interior of an operating system, protecting it from any accidental damage and, hence, the name. There are different types of a shell, such as Korn shell (ksh), Bourne shell (sh), C shell (csh), Bourne Again shell (bash), a remote shell (rsh), etc. A script written in any such environmen­t is referred to as a shell script.

The different operations that can be performed by shell scripts include file manipulati­on, execution of programs, and printing text. A script that sets up the specific environmen­t, runs the program, does clean-ups if necessary, does logging, etc, is basically called a wrapper, which refers to the automated mode of running a specific operating system shell.

 ??  ??

Newspapers in English

Newspapers from India