# Chapter 2. Basic Interactive Functions

## Running Commands and Basic Shell Operation

The shell is a the part of OS-9 that accepts commands from your keyboard. It was designed to provide a convenient, flexible, and easy-to-use interface between you and the powerful functions of the operating system. The shell is automatically entered after OS-9 is started up. You can tell when the shell is waiting for input because it displays the shell prompt. This prompt indicates that the shell is active and awaiting a command from your keyboard. It makes no difference whether you use upper-case letters, lower-case letters, or a combination of both because OS-9 matches letters of either case.

The command line always begins with a name of a program which can be:

- The name of a machine language program on disk

- The name of a machine language program already in memory

- The name of an executable program compiled by a high-level language such as Basic09, Pascal, Cobol, etc.

- The name of a procedure file

If you're a beginner, you will almost always use the first case, which causes the program to be automatically loaded from the `CMDS` directory and run.

When processing the command line, the shell searches for a program having the name specified in the following sequence:

1. If the program named is already in memory, it is run.

2. The “execution directory”, usually `CMDS`, is searched. If a file having the name given is found, it is loaded and run.

3. The user's “data directory” is searched. If a file having the name given is found, it is processed as a “procedure file” which means that the file is assumed to contain one or more command lines which are processed by the shell in the same manner as if they had manually typed in one by one.

Mention is made above of the “data directory” and the “execution directory”. At all times each user is associated with two file directories. A more detailed explanation of directories is presented later. The execution directory (usually `CMDS`) includes files which are executable programs.

The name given in the command line may be optionally followed by one or more “parameters” which are passed to the program called by the shell.

For example, in the command line:

    list file1

the program name is list, and the parameter passed to it is FILE1.

A command line may also include one or more “modifiers” which are specifications used by the shell to alter the program's standard input/output files or memory assignments.

### Sending Output to the Printer

Normally, most commands and programs display output on the computer video display. The output of these programs can alternatively be printed by specifying output redirection on the command line. This is done by including the following modifier to at the end of any command line:

    >/p

The “>” character tells the shell to redirect output (See the section called “Concurrent Execution”) to the printer using the computer's printer port, which has the device name “/P” (See the section called “I/O Device Names”). For example, to redirect the output of the dir command to the printer, enter:

    dir >/p

The xmode command can be used to set the printer port's operating mode such as auto line feed, etc. For example, to examine the printer's current settings, type:

    xmode /p

To change any of these type XMODE followed by the new value. For example, to set the printer port for automatic line feeds at the end of every line, enter:

    xmode /p lf;