Console/Command Line Programming

Using a shell to interpret user commands to perform specific actions.

The aim of this computer programming article is to present console programming, otherwise known as command line programming, and the major platforms that support it.

Introduction

In operating system terms (Un*x, Linux, DOS, Windows, OS/2, MacOS etc.) the console refers to the old teletype-style interface that existed from the very earliest days of computer programming.

Under operating systems such as Windows XP, this is referred to as the Command Line; generically we can think of it using the Un*x and Linux term : shell. A shell is an interpreter that takes input from the user, in the form of commands, and uses them to perform specific actions.

Shell / Console Features

The reason we use the term shell is simple - computer programming can be done on a variety of platforms, through a variety of interpreters. Each 'shell' that encapsulates the command line interface could be a different kind of interpreter:

  • MS-DOS : Microsoft DOS
  • DR-DOS : An MS-DOS alike from Digital Research
  • csh or c-shell : Unix shell interpreter
  • etc...

Generally speaking, the programming hurdles characterized by command line application development are mainly due to the fact that they have very little support for interactivity.

An operating system such as DOS, that has become stable and is no longer being actively developed will also have additional constraints such as being a single-tasking non re-entrant environment. This means that it can only run one task at a time, and that task consumes all the system resources (keyboard, mouse, etc.)

Other shell environments, such as those available under Un*x and Linux, have the advantage that they can provide background processing, with reasonably little interference with the foreground tasks.

Device support is also different in a command line environment, dealt with by offering a special kind of program : the Terminate Stay Resident or TSR application. These can be considered as the forerunners to device drivers.

Programming Issues

There are several programming issues to bear in mind when deciding whether to program under a command line, or console, platform.

Lack of Graphics

While it is possible to display graphics using a variety of reasonably complex operating-system level techniques that talk directly with the hardware, traditional console environments do not offer support for line graphics.

However, the combination of an extended character set, coupled with specially interpreted control codes (also known as ANSI control codes) can be used to reposition the cursor, change color, and display graphic-like (pictograms) elements.

No Native WIMP Support

For those used to the Windows-Icon-Mouse-Pointer application environment, it does not exist in the console environment. Hence, it is not available to programmers. However, many languages such as Modula-2, BASIC, and so forth, provide simple Windowing, text positioning and mouse support.

Where Next?

If you are completely new to programming, you will probably want to return to the General Programming Index, and take a look at some of the other options - such as GUI programming, different languages and so forth.

On the other hand, if you want to get started right now, we suggest following one of the language tutorials (C is about the most cross-platform) and trying your hand at the exercises.

Navigation Links

Guy Lecky-Thompson, Self Portrait

Guy Lecky-Thompson - Guy W. Lecky-Thompson is the author of several technical and non-technical books, and writer at large. He has written for Dr. Dobbs ...

rss
Advertisement
Leave a comment

NOTE: Because you are not a Suite101 member, your comment will be moderated before it is viewable.
Submit
What is 8+8?
Advertisement
Advertisement