The Elementary Amiga
The Amiga Workbench is fine for most applications. It gives you friendly access to most programs and files on disk. But it doesn't show you everything. To probe deeper, and to exercise greater control, you must activate the Command Line Interface (CLI). In this installment, we'll learn to use the CLI.
In many ways, the CLI is a traditional computer interface: You type in commands and receive responses in the form of text (sorry, no icons here). To use the CLI, you must first switch it on.
There are two ways to activate the CLI: an official method, and a quick-and-easy method. You're likely to use both at one time or another. Before using any of these methods, make a backup of your original Workbench disk and use the copy only. This way, your original disk is still available in case any problems occur.
First, we'll go over the official method of activating the CLI. Boot your system with Workbench and run Preferences. On the Preferences display, you'll see an area marked CLI with two boxes labeled OFF and ON. Click the ON box and then click the SAVE box at the lower right corner of the display. Close everything on the Workbench.
Now, when you reopen the Workbench disk, a new icon marked CLI appears in the System drawer. Double click this drawer and then on the CLI icon. A CLI window opens up.
Here's the unofficial method: Start the computer from a power-off condition or reboot by holding down the CTRL, Commodore, and Amiga keys at the same time. (On the Amiga 1000, these keys are designated CTRL, left-Amiga, and right-Amiga.) As the system is reading in the Workbench disk, hold down the CTRL and D keys simultaneously. Wait. The system stops with a BREAK message on the screen. When it does, release the keys. You're now in CLI.
Making A CLI Disk
The next step is to modify a Workbench disk so that the computer comes up in CLI every time. Here's how to do it: Boot with the Workbench disk to be modified and enter the CLI using one of the methods described above. From CLI, type ED S/STARTUP-SEQUENCE and press RETURN.
After a little disk activity, the screen changes to a new text display containing a series of CLI commands. Press the ESC key—this causes an asterisk to appear at the bottom of the screen—and then type B. This combination of key—presses moves the cursor to the bottom of the text file.
At this point, the cursor should be on a line which reads ENDCLI >NIL: or something similar. Press the ESC key—there's the asterisk again—and then type D, for delete. The last line vanishes. If you prefer, you could just type a semicolon (;), inserting that character before the ENDCLI command. The semicolon acts like BASIC'S REM statement, keeping the ENDCLI command from being executed. That's effectively the same as deleting the line.
If everything has gone as expected, press ESC one more time and then press the X key. The edited file is written to disk, replacing the original startup file. If by any chance you made a mistake—you pushed the wrong key, perhaps—press ESC and then Q, for quit. The computer asks if you really want to quit. Answer by pressing Y, and start over again from the ED S/ STARTUP-SEQUENCE command.
From now on, this disk gives you the CLI every time you boot. To exit the CLI, just type ENDCLI and press RETURN (from now on, assume that all CLI commands are followed by the RETURN key). The CLI window disappears, leaving you with the Workbench screen. Most users leave the CLI active, however. It's easier to shrink the CLI window using the sizing gadget in the lower right-hand corner, and then click the back gadget to put it behind other windows on the Workbench screen. This way, the CLI sits there, waiting for you. Any time you need it, simply bring it to the front and click inside of it.
How It Works
The above procedure may seem puzzling at first, but it makes more sense as you learn more about your Amiga. We'll give a little background on the workings of the Amiga as its starts up, and then explain the modifications that we've made.
When the computer boots with the Workbench disk, it begins with a CLI window. This is where you see the copyright notices and release version number. During startup, the CLI doesn't wait for you to enter commands from the keyboard. Instead, it takes its instructions from a file called STARTUP-SEQUENCE.
A file containing CLI commands, such as STARTUP-SEQUENCE, has many names. Users with an MS-DOS background may use the term batch file. Another name, script file, comes from the idea that you can read the file (it's stored as text) and that the file contains a list of instructions. More accurately, however, I like to call it an execute file, since you can activate these files using the CLI command EXECUTE.
The computer doesn't care what you call it; it just searches the disk for a file called STARTUP-SEQUENCE. If it doesn't find it on the main part of the disk, it looks in the drawer called S, for Sequence. When it finds the file, it executes the commands it finds there. Some of these instructions put information on the screen (ECHO). Some of these commands adjust the way you access the disk (PATH). An important instruction, LoadWB, loads in the Workbench. The last instruction found in the standard startup file tells the CLI to self-destruct. That's the ENDCLI command.
Although the startup sequence begins automatically, we can stop it by holding down the CTRL and D keys. When pressed simultaneously, these two keys tell the computer, "if you're executing instructions from a file, stop doing so." This is what happens when you use the unofficial method of accessing the CLI. Because the CLI aborts the startup sequence, it never gets to the ENDCLI instruction. Chances are, however, that the CLI never got to the LoadWB instruction either. If this is the case, the Workbench was never loaded and entering the ENDCLI command will lock up your computer, forcing you to reboot—no CLI, no Workbench, no computer.
To create a Workbench disk that boots up with the CLI active, we used a screen editor that comes on the Workbench disk called ED. There are other editors available—some of them quite marvelous—but everyone has good old ED, and it does the job just fine. By entering the command ED S/STARTUP-SEQUENCE, we ask the program ED to start, and to look in drawer S for a file called STARTUP-SEQUENCE. If found, the file is displayed on the screen where we can edit it.
When ED is running, the ESC key triggers what are called extended commands. All extended commands are prompted by an asterisk that appears on the bottom line of the screen. We used the extended commands: B, for go to bottom line; D, for delete the current line; and X, for exit the editor with file update. Extended command Q, if we needed it, caused the editor to quit without changing the file.
What did we do with STARTUP-SEQUENCE? We just eliminated the ENDCLI command at the end of the file. All the other commands in the startup sequence were left untouched. After editing the startup sequence, the Amiga boots as usual, except that the CLI remains on the screen. We could use the command ENDCLI and close the CLI window, but it's better to just move it out of the way when it's not in use.
First CLI Commands
The official CLI reference is The AmigaDOS Manual, published by Bantam Books. Be sure you get the revised edition—new CLI commands have been added since the book was first published. Here, I'll show a few commands that you can experiment with.
If you have an Amiga 1000 or an unexpanded Amiga 500, you have to set the date and time every time you turn on your computer. Normally, we set the time using Preferences, but that requires a lot of mouse clicking. With the CLI's DATE command, it's a snap. For example, type DATE 25-Dec-87 11:20, and the job is done (assuming it's December 25, 1987, at 11:20 a.m.). Any time you want to know what the current date and time are, just enter DATE by itself and the computer responds obligingly.
Type DIR to get a directory listing of the current drive (drive 0). You can get the same listing by specifying drive 0 with the command DIR DF0:. If you have a second drive, you might like to put a disk in there and type the command DIR DF1: to see its contents.
If you have a printer, try making a hard copy of the directory. It's easy by using a feature called I/O redirection. The command DIR >PRT: DF0: sends the DIR command's output to the PRT: device (your printer). You could just as easily send the directory listing to a disk file. For example, the phrase >DLIST following a DIR sends everything to a file called DLIST. Pictorially, the greater-than sign (>) looks like an arrow, or a funnel. Think of redirection as a command to "pour" output to the given destination. Keep in mind that the redirection phrase must come immediately after a command.
You may notice that your disk has many drawers, or as the CLI calls them, directories. If you want to look inside a directory called Utilities, you give the command DIR UTILITIES (or DIR DF0:UTILITIES) and see what's in there. Or you could command DIR DF0: OPT A and see everything on the disk. OPT A, by the way, stands for OPTion All.
Icons And Info Files
In a disk directory listing, you'll see a number of files whose names end with .info. You might think these files contain information or documentation on the associated program. Not so. These files hold Workbench display information: the shape of the file's icon, location of the icon in the disk's file window, and some of the other things seen when we use the Info option from the Workbench menu.
Most files have info files associated with them. Thus, if you have a program named DONKEY, you probably have a DONKEY.INFO file as well. This allows DONKEY to appear as an item on the Workbench. If you were to delete DONKEY.INFO, the program DONKEY would no longer appear in the Workbench display, but it would still exist and could be used from CLI.
Similarly, if we had a file called MONKEY which has no info file, we could make one by using the command COPY DONKEY.INFO TO MONKEY.INFO. The file MONKEY would then appear on the Workbench, but with one surprising result: The icons for both DONKEY and MONKEY would be located in exactly the same place, one on top of the other. To produce a sensible display, you would need to drag one of the icons to a new area and "log in" its new position with the Workbench's Snapshot option.
Don't assume that the CLI and Workbench are interchangeable. Many programs designed to work from the CLI do not work from the Workbench. That's usually because the CLI provides a ready-made screen area for input and output; a program running from the CLI may use what's already there. Workbench, in contrast, has no ready-made text window, and a program running under Workbench must know how to create such a window if needed.
DIR And LIST
We've used DIR to look at the contents of a disk. We may also use LIST to obtain a directory. Try LIST DFO: and see the difference. List not only displays the filenames, but the file size, protection status, date of creation, and any comment associated with a file.
The options for LIST are quite different from those of DIR. You can't use OPT A, for example. All commands may use redirection—that's part of the system's workings, not the command itself.
If you're not familiar with a command's syntax, type the command name followed by a space and a question mark. You'll be prompted by a description of the command's parameters (from now on referred to as a template). Thus, if you type DIR ? you see the template: DIR, OPT/K.
We read this as follows: The system needs the name of a DIRectory path (DFO: will do), followed, possibly, by OPTions. The K means that if you use options, you must precede them with the OPT keyword. (If the K were not there, it would mean you could omit the OPT keyword, and just supply the optional information.)
If we type LIST? we see a much longer template. Again, DIR indicates that we may supply the name of a directory path, but then we see a long list of available options. I'll mention only a few here.
P = PAT/K is for filename pattern matching. P = PAT means that we may use either keyword P or PAT to activate pattern matching. The /K implies that if we use this option, we must enter either P or PAT. Space doesn't allow an indepth discussion of pattern matching here, but here's a brief example that lists all files whose filename ends with .INFO: LIST P #?.INFO.
QUICK/S is an option that allows you to get a short or "quick" directory. (A quick LIST displays the names of the files and directories only.) The /S indicates that the keyword QUICK is a switch. By using the QUICK option, you switch on this feature.
For a third example of a command template, type COPY ? and you'll see FROM, TO/A, ALL/S, QUIET/S.
The FROM and TO parameters are flagged with /A, signifying that we must supply both the source and destination filenames—you must copy from somewhere to somewhere else. Anytime you're not sure about a command, type the question mark and examine the template.
There are a large number of commands available in CLI. You can see a list of these by typing DIR C:, or if you prefer, LIST C:. You don't need them all, by any means. We'll take a look at some of the more useful ones in the next few months.