------------------------------------- 3]THE SHELL GAME: A Continuing Column 3]For Beginners and for Review 3]By Brad Webb ------------------------------------- 3]FOR STARTERS -- You are given two ways of accessing this month's Shell Game column. With variations, both let you open a Shell and try Shell commands as as you read the column. 1. If you entered this article through the Article Menu, press the LEFT-AMIGA and N keys simultaneously to bring the Workbench screen forward. Press the LEFT-AMIGA and M keys to bring the article back to the fore. 2. If you entered by clicking on the ShellGame icon in the main J window, you may resize the PPMORE window smaller by clicking and dragging on the sizer gadget at southeast of the window. This way allows you to have the column and a Shell window on the screen at the same time. In both cases, you must open a Shell window in order to type in the AmigaDOS commands. 3]START OF SOMETHING GOOD January is a month of beginnings. The start of a new year for us all, it is the start of new computing experiences for many who received a computer for Christmas. This Shell Game column will introduce the Amiga Shell to those of you new to the Amiga. Regular readers are invited to treat this column as a review. The most important use for the Shell is to use something called AmigaDOS, so that will be the topic of the column. One of the things we must do in this introduction is define a few terms -- enough so you aren't confused by the different names for some of what's available to you when working in the Shell. Most basic is the definition of the Shell itself and why you should even care about it. The Shell is a special window which you can open by double-clicking its icon. Once open, it provides a way for you to interact with your Amiga which is different than the Workbench mouse and icon method. In the Shell the Amiga provides you with a prompt stating it is ready for you to enter a command. You type in a command and the Amiga responds to it. This method of interacting with a computer is more like the method used by IBM PCs, Commodore 64s, Apples and so on. The Amiga is unusual in allowing you the two ways of communicating your wishes to it. The prompt will look something like: 1.Workbench1.3> . . . with the point aimed where you will type your commands. There are many reason for learning to use the Shell. Probably the most important is that it allows you finer control over the computer when you need it. In addition, there are many things that are just easier to do from the Shell. Finally, there are some programs, including many public domain gems, that must be run from the Shell or not at all. 3]SO THEN WHAT'S A CLI? You have probably heard or seen the term CLI. The CLI (Command Line Interface) is an earlier, more primitive version of the Shell. It is less easy to use but accomplishes the same ends. While the Shell icon lives in the Workbench disk "root" window (the window that opens first when you double-click on the disk icon), the CLI icon lives in the System drawer. It has been retained for compatibility with some early programs that require it. I will be discussing the Shell in this column, but don't hesitate to try what I describe in a CLI window too. Most commands work both places. By the way, CLI is always pronounced "see-ell-eye", not "kly." 3]THIS EQUALS THAT AND SO ON One or two other terms must be covered before we go on. In the Shell, the "directory" is the equivalent of a Workbench drawer. It consists of a list of items on a disk. All disks have at least one directory, called the root directory. It is equivalent to what you see when you double-click on a disk's icon and open its first window. The root directory can itself contain sub-lists of items, appropriately called subdirectories. These are what you see as drawer icons from the Workbench. Everything in a directory list except other directories is called a file. A file is nothing more than a set of information in a form the Amiga can understand. All files have names, and it is these names that appear in directories and subdirectories. Files come in two types -- "programs" equivalent to Workbench "tools," and "data files" equivalent to Workbench "projects." Example: a word processor like WordPerfect is a program, a letter written with WordPerfect is a data file. The reason you can have directories listed in other directories is because Amiga disks hold so much that putting every file into one list would make it impossible to find anything. 3]TIME TO TAKE A LOOK Now that we have a few terms out of the way, let's look at some examples. This will make things clearer. I suggest you print this column using JUMPDISK's print utility. Then reboot the system using a COPY of Workbench, not the original disk, and follow along from this point. As an alternative, if you have enough memory and two drives you could keep open the window in which you are reading this and work the experiments that follow in a second window. This method uses the Amiga's multitasking ability. You may want to first read this paragraph and the next, as this window gets a bit hard to read in once it's been made smaller. If you have opened this file by clicking its icon, rather than going through the Article Menu, you can shrink this window by placing the mouse pointer over the sizing gadget, the double squares in the window's lower right corner. Then press and hold down the left mouse button. Drag the mouse pointer up to shrink the window until you can see the Workbench disk icon. You may have to temporarily drag the sizing block to the left to reveal the disk icon. Once you have a Shell window open (I'll tell you how to do that in a moment), you can make this window larger by dragging in the other direction. Everyone should double-click on the Workbench disk icon. In the window that opens you will see a Shell icon. Double-click on the Shell icon and its window opens. If you are multitasking, you may wish to move the Shell window down the screen. Place the mouse pointer over the bar at the top of the Shell window. Press and hold down the left mouse button and drag the whole window south on the screen. Then resize this window if you wish. If you are using the multitasking method to read this, remember to click the left mouse button once with the pointer in the Shell window before typing any commands. This makes the Shell window the "active" window. Forgetting this will cause the commands to be ignored. You can tell if a window is active or not by looking at the drag bar at its top. If it is solid, the window is active. If the bar is "ghosted," the window is inactive. 3]LET'S TRY SOME DOS COMMANDS For the rest of this column, we will be looking at some of the most useful AmigaDOS commands. DOS means "Disk-based Operating System" and is a part of the Amiga's operating system only available from the Shell and CLI. Type the following commands in the Shell window, pressing the RETURN key after each. The RETURN key is the large L-shaped key. bent arrow on it. Important: It's assumed from here on that you have started the computer with a COPY of a standard Workbench disk. In the shell, type: cd df0: {This means to press the C key, the D key. the space bar, the D key, F key, 0 key, colon key and then the RETURN key} Next, type: dir You should see the following: Trashcan (dir) c (dir) Prefs (dir) System (dir) l (dir) devs (dir) s (dir) t (dir) fonts (dir) libs (dir) Empty (dir) Utilities (dir) Expansion (dir) .info Disk.info Empty.info Expansion.info Prefs.info Shell Shell.info System.info Trashcan.info Utilities.info Congratulations, you have just opened a Shell window, and used two DOS commands. What you see on the screen is a directory listing of the Workbench disk. It is the equivalent of what you see in the window on Workbench when you first open the Workbench disk by double-clicking on its icon. 3]CD = CURRENT DIRECTORY The first command, CD, establishes a "Current Directory". This is the directory on the disk where all other commands will do their work unless specifically told to work elsewhere. You can always "get to" the equivalent of a disk's first window by typing CD followed by the name of the drive, as we just did to get to the "root" or "first window" directory of the Workbench disk in drive df0: 3]DIR SHOWS YOU WHAT'S THERE The second command, DIR, presents you with a sorted list of the directory that is current. Sharp eyes may have noted there is much more here than you see when viewing the first window from the Workbench disk. Let's explain some of the differences. 3].INFO FILES ARE REALLY ICONS Everything with (dir) after it is another directory list, and you would perhaps expect them all to have drawer icons in the Workbench window. Well, it doesn't work that way. Note that directories C, S, T, L, fonts and libs have no drawers visible when the Workbench window is opened. Now, look at the files listed here. Files are everything that is not a directory. For some of the directories there are matching files with a .info extension. These .info files are actually the icons you see in a Workbench window. Important to remember: Unless a directory or file has a matching .info (icon file), it will never appear in a Workbench window! This is why you don't see, for example, the C directory from the Workbench, though it is on the disk. You have just been presented with a very important reason for knowing a bit about the Shell. There are things you just can't get at from the Workbench. These include directories like C and many public domain programs and data files. Many casual Amiga users will never be bothered by this, but a much of the Amiga computing world will be blocked to them. 3]MORE ABOUT DIR Now, in the Shell type: dir c Your Amiga drive will spin a while as the files are put into sorted order, and then all the files in the C directory will be listed to the screen, in two columns. Many file names will go by! Each of these files represents an AmigaDOS command, available to you in the Shell or CLI but nowhere else. Each of these commands can do something for you once you are familiar with it. You should be beginning to glimpse the power of the Shell and DOS. You have just seen how to show the contents of a directory other than the current directory. You type the DIR command followed by the name of the directory of interest. This only works for directories that you can see in the current directory list. Try this. At the Shell prompt type: cd c Note the prompt changes to: 1.Workbench1.3:c> You have made the C directory the current directory and the prompt changes to show you this. Now, type: dir Once again you will see all the files in the C directory. This time, because C is the current directory, it was not necessary to specify its name to get the listing. Suppose you are "in" the C directory as you are now, and you want to see something in another directory not contained in the C directory. How do you do this? The answer is to type out the full "pathname" to the other directory of interest. For example, type: dir df0: . . . and get a list of the root directory to remind what is there. One of the directories you can see in that list is DEVS. Though you are "in" the C directory, you can get a look at DEVS if you wish. Type: dir df0:devs . . . to see what is contained in the DEVS directory. 3]GOING UP Now that you are down in the C directory, how do you get back up? Remember I said earlier you can always type the CD command and a drive name to get to the "root" or first directory on a disk. In this case (don't type this in yet) you could try: cd df0: . . . to get back to the root level. Another way to move up is by using a slash (/). For every slash you use with the CD command, you move up one level. Type: cd / Voila! The prompt will change and show you that you are at the root level (one up from C) in df0: Issue a DIR command to see the familiar file and directory list. 3]ANOTHER WAY OF LOOKING AT DIRECTORIES I used the words "directory list" just now. That's a sneaky way of moving to the next command I want to show you, LIST. Like DIR, it is used to display a directory. Unlike DIR, LIST shows you more information about each directory and file. It does not sort the names first and so is a bit faster. In the Shell type: list You should see: Expansion.info 894 ----rwed 13-Aug-88 18:02:32 Trashcan Dir ----rwed 13-Aug-88 18:02:34 .info 70 ----rwed Today 20:07:43 c Dir ----rwed 23-Sep-89 12:10:59 Prefs Dir ----rwed 13-Aug-88 18:16:15 System Dir ----rwed Saturday 20:57:35 l Dir ----rwed 23-Sep-89 12:44:11 Shell empty ----rwed 13-Aug-88 18:08:18 devs Dir ----rwed 23-Sep-89 12:46:56 s Dir ----rwed 13-Aug-88 18:09:30 Shell.info 405 ----rwed 13-Aug-88 18:09:36 t Dir ----rwed 20-May-89 19:54:02 fonts Dir ----rwed 13-Aug-88 18:11:03 libs Dir ----rwed 23-Sep-89 12:49:56 Empty Dir ----rwed 13-Aug-88 18:11:48 Utilities.info 894 ----rwed 13-Aug-88 20:02:19 Disk.info 370 ----rwed 13-Aug-88 18:11:55 Prefs.info 894 ----rwed 13-Aug-88 18:11:57 System.info 894 ----rwed 13-Aug-88 18:12:01 Empty.info 894 ----rwed 13-Aug-88 18:12:05 Trashcan.info 1166 ----rwed 13-Aug-88 18:12:09 Utilities Dir ----rwed 23-Sep-89 12:52:39 Expansion Dir ----rwed 13-Aug-88 18:13:31 10 files - 13 directories - 39 blocks used This display shows all the files and directories we are used to seeing by now, but lists them all in column form. In the second column, the word Dir indicates a directory. Files are shown by size in bytes. Each byte is equivalent to one character, like a letter in a file consisting of words. Note the Shell file is listed as "empty". It's strange, but the Shell "file" is actually a special file with nothing in it. It may not make sense, but it works. After the size is a column with the "protection bits." The rwed tell you the file or directory can be Read, Written to, Executed if a program and Deleted. The dashes represent other possibilities not available with these files and directories. Finally, each entry has the date and time of creation (if set properly at the time the file or directory was created). The LIST command is good for getting some idea of how big a file is. 3]INFO, SHORT FOR INFORMATION, IS VERY HANDY Now type: info What you see will depend on your exact system configuration but should look something like: Mounted disks: Unit Size Used Free Full Errs Status Name FAST: 40M 52874 28639 64% 0 Read/Write DH1 DF0: 880K 1751 7 99% 0 Read/Write Workbench1.3 RAM: 2K 5 0 100% 0 Read/Write RAM DISK DH0: 637K 1164 109 91% 0 Read/Write DH0 Volumes available: Workbench1.3 [Mounted] RAM DISK [Mounted] DH1 [Mounted] DH0 [Mounted] This is the display for an Amiga 2000 with a hard drive. The hard drive has two partitions, DH0: and FAST:. INFO lists all the disks available to your computer, including the RAM: disk. It also tells you their sizes in bytes, how much is used in disk blocks (one block holds 512 bytes), how much is free (again in blocks), the percentage full each disk is, whether you can read and write to or just read the disk, and the name of the disk. I don't know why Used and Free are in blocks instead of bytes, but they are. Just remember each block holds about 500 bytes and you'll do fine. At the bottom of the display is a short summary of all the disks the computer knows about. If it is aware of any disk but the disk is not actually in a drive, its name will be shown but the [Mounted] designation will not be there. This display is much more informative than the "gas gauge" of the Workbench when you need to know how much space remains on a disk. 3]KEYWORDS AND ON LINE HELP Brace yourself, here comes a topic that's a bit confusing but worth looking at. The topic is the Amiga's on-line DOS help. For most AmigaDOS commands, there is a way to have the computer give you some help in using the command. To understand this help, though, you first have to know what a "keyword" is. Most commands, like DIR and LIST, have "keywords" associated with them. A keyword is a modifier. Using a command and one of its keywords makes the command work in a modified manner. This is easier to show than to explain, so here's an example. Type: list block Expansion.info 2 ----rwed 13-Aug-88 18:02:32 Trashcan Dir ----rwed 13-Aug-88 18:02:34 .info 1 ----rwed Today 20:07:43 c Dir ----rwed 23-Sep-89 12:10:59 Prefs Dir ----rwed 13-Aug-88 18:16:15 System Dir ----rwed Saturday 20:57:35 l Dir ----rwed 23-Sep-89 12:44:11 Shell empty ----rwed 13-Aug-88 18:08:18 devs Dir ----rwed 23-Sep-89 12:46:56 s Dir ----rwed 13-Aug-88 18:09:30 Shell.info 1 ----rwed 13-Aug-88 18:09:36 t Dir ----rwed 20-May-89 19:54:02 fonts Dir ----rwed 13-Aug-88 18:11:03 libs Dir ----rwed 23-Sep-89 12:49:56 Empty Dir ----rwed 13-Aug-88 18:11:48 Utilities.info 2 ----rwed 13-Aug-88 20:02:19 Disk.info 1 ----rwed 13-Aug-88 18:11:55 Prefs.info 2 ----rwed 13-Aug-88 18:11:57 System.info 2 ----rwed 13-Aug-88 18:12:01 Empty.info 2 ----rwed 13-Aug-88 18:12:05 Trashcan.info 3 ----rwed 13-Aug-88 18:12:09 Utilities Dir ----rwed 23-Sep-89 12:52:39 Expansion Dir ----rwed 13-Aug-88 18:13:31 10 files - 13 directories - 39 blocks used Once again we see the output of the LIST command, but notice the difference. This time the size column does not show the file sizes in bytes. Instead, the file size is shown in disk blocks. This can be a very handy thing to use with the INFO command to see if a floppy has enough free space to hold a specific file. The keyword BLOCK modified the command LIST in this example. The Amiga's on-line help can be used to show you the keywords you can use with a given command and to give you a hint as to how to use them. To call up the on-line help for a command, type the command name and a question mark. As an example, call up the on line help for DIR. Type: dir ? You will see: DIR,OPT/K,ALL/S,DIRS/S,FILES/S,INTER/S: . . . showing the keywords DIR understands are OPT, ALL, DIRS, FILES and INTER. For now, press the RETURN key. The DIR command will take action. After showing you the help line, properly called an "argument template", DOS commands wait for you to type in any keyword or argument you wish, and then perform their duties. There is not enough space here to go into detail about each keyword. Briefly, FILES will cause DIR to show only files, (type "dir files"), DIRS will show only directories (type "dir dirs") and ALL -- well, try that one. Type: dir all What did you see? Was it what you expected? DIR ALL shows every file and every directory "down" from the current directory. It will not show any "above" your present position. 3]/K/A/S ARE CLUES FOR YOU The example argument template has /S or /K after the keywords. You will also see /A with some other commands. These three cryptic bits of information have the following meanings: /A means you must supply some information to the command (an "argument" hence "A"). The word preceding the /A will explain what sort of information is needed. /K means the keyword (such as OPT in the example) must be typed out in order for it to be effective, and an argument of some sort must be supplied. /S means the keyword is a "switch". All you need to do is to type the keyword to have it modify the command. No argument is required. Note that "dir files" and "dir dirs" are switch type usages. 3]A /K AND A /A EXAMPLE Until you get familiar with AmigaDOS, /S type keywords will be of most use to you. Just for familiarity's sake, here are two examples to look at. One uses a /K keyword and one a /A keyword. Type: list ? . . . to see the argument template for LIST. It's almost overwhelming, isn't it? We'll take our /K example from it. You should have seen: DIR,P=PAT/K,KEYS/S,DATES/S,NODATES/S,TO/K,SUB/K,SINCE/K,UPTO/K,QUICK/S, BLOCK/S,NOHEAD/S,FILES/S,DIRS/S,LFORMAT/K: I had to put it on two lines to make it fit. If you get the feeling LIST is a strong command once you know it well, you are right. The keyword SINCE is of the /K variety. Type: since 13-aug-88 Remember what I just said: When the argument template is called, the computer is waiting for you to enter keywords if you wish. There is no need to retype the command LIST at this point. It is still active until you press the RETURN key. Only files created on or after that date will be LISTed. That will probably be all or most of them on the Workbench disk. 3]THE NEXT TO LAST COMMAND FOR THIS COLUMN: COPY For the /A example, we will use the COPY command. You can use COPY to make copies of files from the Shell, just as you use the Workbench's "Duplicate" function to make copies from the Workbench. Let's start by looking at the argument template for COPY. Type: copy ? You will see: FROM,TO/A,ALL/S,QUIET/S,BUF=BUFFER/K,CLONE/S,DATES/S,NOPRO/S,COM/S: The TO keyword has a /A indicator, so let's try that keyword. Press RETURN to get another DOS prompt, ignoring the error message, which just indicates you didn't finish typing the required COPY command argument. In the Shell window type: copy prefs.info to test.info Now, typing: dir . . . will show the new file, TEST.INFO does exist. Actually, a /A indicator only means you need an argument described by the keyword, not the keyword itself. In other words, copy needs to know what TO call the copy it makes. It can't copy anything without that information. That is why you received the "Bad arguments" error message a moment ago. You hadn't typed a TO argument before pressing RETURN. So a /A indicates a required argument. Only if the /A appears with a /K do you absolutely need to type the keyword itself, otherwise it is optional. Both "copy disk.info to test.info" as we typed the command and "copy disk.info test.info" without specifically typing TO would have worked. If the argument template had shown "TO/A/K" then you would have been required to type the actual keyword TO in order for the COPY command to have worked. If you find all the /A,/K and /S matters confusing, re-read the above once or twice and then don't worry about it. AmigaDOS commands are so flexible, the best thing to do is just to use portions that do what you want and only worry about the rest as you need more functions later. 3]OUR LAST COMMAND - DELETE Be careful with this one. It is used to remove files and empty directories from disks. There is no way to reverse the process. We created a new file a moment ago (test.info). It will provide a handy "victim" for the DELETE command. In the shell type: delete test.info Now, issue another DIR command to prove to yourself TEST.INFO is gone. 3]SUMMING UP In this column I have covered the barest bit of the called the Shell and by extension the CLI. The specific things I had you do with DIR, CD, INFO, DELETE, LIST and COPY will be of value to you in your day-to-day computing. Use the examples I've shown you and experiment. If you are interested in learning more about the Shell and it's DOS commands, there are several things you can do. Read the manual that came with your AmigaDOS 1.3 Enhancer software for starters, and check through the manuals that came with your computer. There is some beginner's information there too. You could pick up a copy of the "AmigaDOS Manual" from Bantam Books. It covers all the commands and gives examples of use. For a complete hands-on course on using AmigaDOS 1.3 you can (ahem!) pick up my diskbook "DOS Lab", which is written along lines similar to this column. There's an ad elsewhere in this issue. You can also experiment on your own, checking the argument templates and trying things. Always use copies of disks and you have nothing to fear. Come back here every month for various discussions about using the Shell. There is much more than AmigaDOS available there. We'll explore these topics together. 4]END OF TEXT