Copyright (c) Hyperion Entertainment and contributors.

AmigaOS Manual: AmigaDOS Working With AmigaDOS

From AmigaOS Documentation Wiki
Jump to navigation Jump to search

AmigaDOS stores information in the same hierarchical structure as Workbench. AmigaDOS commands have specific rules that you must follow when creating and programs to run on your Amiga. You must be familiar with the terms specific to the file system and with AmigaDOS command concepts to successfully use AmigaDOS. This chapter describes the following:

  • Managing files, directories, and disks
  • Command line basics
  • Types of commands
  • Command structure
  • Special characters
  • Running programs
  • Refining your AmigaDOS environment

Specific commands are fully described in Chapters 6 and 7 of this manual.

Managing Files, Directories, and Disks

In order to use AmigaDOS to access information, you must know where that information is located. On an Amiga, all information is stored in a system of directories and files. This is the same system used by the Workbench, only the method of working with it is different. Most notably, you do not use icons to manipulate the files and directories. See the Workbench User's Guide for detailed information aboutthe Amiga file system and the use of common commands. Use this section to review the following AmigaDOS basic concepts:

  • File system terms
  • File management
  • Naming conventions
  • Keywords

File System Terms

The following are the main elements of the AmigaDOS file system:

Device
A physical device, such as disk drive or printer, or a software (logical) device, such as RAM: or the printer device PRT:.
Partition
A hard disk or part of a hard disk that AmigaDOS treats as a separate device.
Volume
A particular disk or subdivision of a hard disk that AmigaDOS treats as a separate device. Floppy disks and hard disk partitions are volumes.
Directory
Equivalent to a drawer in Workbench.
Root Directory
The top of the filing system for a given volume; the directory that contains all other directories.
Subdirectory
A directory that is contained within another directory.
File
A named collection of data.
Path
The series of device, directory, and subdirectory names that uniquely specifies a particular file and its location.

File Management

AmigaDOS stores information on a device in a file system, which is an organization of directories, subdirectories, and files. Directories and files are arranged in a hierarchical system often referred to as a tree. The branches are directories, which can include subdirectories. At th ends of the branches are the files, unless the directory is empty. Figure 3-1 illustrates a directory tree.

Example Directory Tree

Devices

Devices include logical devices and the hardware associated with your Amiga, such as floppy disk drives, hard disk drives, the Ram Disk, RAD:, and peripheral devices. Information stored on these devices can be accessed using a variety of names.

To access files on a particular volume, you can refer to the volume by its volume name, such as Workbench:, or its device name, such as DF0:. Use the names interchangeably; however, you must always include the colon (:) after the name. When you refer to a disk by volume name, the system searches all the available drives for the volume. If it cannot find a volume of that name, a requester asks you to insert the volume. When you refer to the disk by a particular device name, the system uses whatever volume is inserted in that device.

AmigaDOS has standard names assigned to peripheral devices that are attached to the various ports, as well as to various logical (software) devices. Generally, these devices are used for output, such as copying a file to a printer. The standard device names are:

APPDIR:
AUDIO:
AUX:
CON:
Represents a console, which uses a window to accept typed input and display text output. The Shell window is one kind of console window.
CONSOLE:
Represents the current console window. An asterisk (*) can also be used in place of CONSOLE:.
DF0:
Represents the Amiga's main internal floppy drive from which the Amiga attempts to boot if there is no other bootable device available.
ENV:
NIL:
Represents a dummy device commonly used to prevent output from appearing on the screen. All output sent to NIL: is discarded.
PAR:
Represents any device, usually a printer, that is connected to the parallel port. If you copy a file to PAR:, it is sent to the device attached to the parallel port. Output directed here is not modified by any driver software.
PIPE:
PIPECON:
PRT:
Represents the printer. Output to PRT: goes through the selected printer drive and to the serial or parallel port as specified in the Printer editor in the Prefs drawer.
RAD:
Represents a special kind of Ram Disk that is only lost if the system is turned off, but not when rebooted. Refer to Appendix C for detailed information.
RAM:
Represents the Ram Disk, which is a portion of the Amiga's internal memory that can be used as a storage device. All information in RAM: is lost if the Amiga is rebooted or turned off.
RANDOM:
RAW:
SER:
Represents any device connected to the serial port, such as a printer or a modem. Output directed here is not modified by any driver software.
SYS:
Represents the volume on which the Amiga looks for its basic disk-based resources, such as C: and LIBS:.
SWAP:
TCP:
Represents Amiga's network resources.
TEXTCLIP:
URL:

Directories

Directories are the AmigaDOS equivalent to drawers in Workbench. They allow you to group and classify related files. Each file on a disk is located in a directory. An empty, formatted disk contains one directory, the root directory. If you create a file on an empty disk, that file resides in the root directory. If the file has an icon attached to it, the icon appears in the disk window.

Directories can contain other directories, called subdirectories. The Amiga supports an arbitrary number of nested directories (directories within directories).

Files

A file, the basic unit of storage on a computer, is an organized collection of information. All the programs and any permanent data that a program uses or produces are files. Project icons represent data files. Data files contain the information created or used by a program, such as text, graphic, or spreadsheet files.

.Info Files

Another type of file used by the Amiga is a .info file (pronounced dot info file). The .info files contain the icons that appear on the Workbench screen. Every file or directory that has on icon also has a corresponding .info file. In addition to storing the graphics and position data for the icon image, a .info file contains any Default Tool or Tool Type information entered into the icon's Information window.

When working through the Shell, AmigaDOS does not automatically associate .info files with the corresponding files or directories. For example, if you use the COPY command to copy the Clock file from the Utilities directory to the System directory, the Clock.info file is not copied with it like it is when you drag the Clock icon from one drawer to another in Workbench. In AmigaDOS, to be sure the Clock icon appears in the System drawer, you must also copy the Clock.info file.

When you change icon images by copying .info files, you need to copy an icon of the same type as the item it represents: Tool, Project, Drawer, Disk, or Trashcan. If the icon's type does not match the type of file it represents, it may not open from the Workbench. Icon type is displayed in the icon's Information window and can be changed with the IconEdit program.

Each disk icon has a corresponding disk.info file. If you delete the disk.info file, a default disk icon automatically replaces the previous icon.

Naming Conventions

The following naming conventions apply to file and directory names:

  • Names can be up to 30 characters long and can contain upper case letters and any punctuation marks that are not reserved. Workbench file and drawer names can only be up to 25 characters long to accommodate a possible .info extension.
  • Colons (:) and slashes (/) are reserved and cannot be used in file or directory names. Semicolons (;), asterisks (*), parentheses (()), question marks (?), back apostrophes (`), number or pund signs (#), square brackets ([]), angle brackets (<>), tildes (~), vertical bars (|), dollar signs ($), double quotation marks ("), and percent signs (%) are not reserved; however, we recommend that you do not use these characters in your file or directory names because they have special meaning in AmigaDOS.
  • Capitalization used in file names is preserved even though AmigaDOS is not case-sensitive. The name is recognized by the characters; for example, TextFile is treated the same as textfile.
  • Spaces in names are allowed, but not recommended when working through AmigaDOS. If you do use names with spaces, the entire path containing the name must be enclosed in double quotation marks. We recommend using an underscore (_) as a separator rather than a space.
Note
If your use spaces in file names, do not place one at the beginning or end of the name. This space is invisible when displayed and easily overlooked as part of the file name. AmigaDOS does not recognize the name if such a space is not entered.

Keywords

A keyword is a special word recognized by an AmigaDOS command. AmigaDOS commands use keywords to identify arguments or to specify options. If there is a conflict between a name and a command keyword, enclosing the name in quotation marks ensures that it is interpreted as a name. For example, if you have a directory named Files and you want to display information about all of its files and subdirectories, you might use the command LIST Files. However, this is ambiguous because LIST has the keyword FILES: To avoid this, enter:

LIST "Files"

Command Line Basics

Effectively using a Command Line Interface, such as the Amiga Shell, requires that you understand concepts unique to this method of working with your computer. These include:

  • The distinctions between files, programs, commands, and scripts
  • The search path
  • The current directory

Files, Programs, Commands, and Scripts

Files, programs, commands, and scripts are named collections of data that can be stored in the computer's memory or on a disk drive. These concepts can be confusing because the meanings of the terms often overlap.

Files

Programs, commands, and scripts are all files. Files can be stored on disk or in the Amiga's memory, although certain kinds of files are customarily stored in specific locations.

Programs

A program is a file that the computer executes to accomplish some task. Software that you buy for the Amiga are mostly programs. Workbench programs are called tools, utilities, or editors. A file that is not a program is typically a data file, which contains information a program can use, such as text or graphics. Programs can be stored anywhere.

Commands

A command is a type of program. The term command usually refers to programs that are executed through a command line such as the Shell, especially those programs that come with a computer as part of the operating system and perform some basic function. The programs detailed in Chapter 6 of this book are the AmigaDOS commands. AmigaDOS commands that are not Internal (built into the Shell) are stored in the C: directory.

The term command can also refer to a specific instance of that program's invocation, including its arguments, if any. In this manual, the term command line is used to indicate a command program's invocation; for example, "The command line TYPE S:User-startup is an example of the TYPE command." The command must always be the first thing on the command line.

Scripts

A script is another type of program that is a text file containing a series of commands comprising the program. You can view and edit a script with a text editor. A script typically performs some simple task than can be modified by editing the script.

In this manual, the term script refers to scripts of AmigaDOS commands. AmigaDOS scripts are customarily stored in the S: directory. ARexx programs are also called scripts, although they can the S: directory using the assignment REXX:. Some computer systems refer to scripts as batch files.

Search Path

When using the Shell, the Amiga must know where to look for the commands you want to use. The Shell has a search path, which allows you to enter commands without providing the full path. The search path is a series of directories that AmigaDOS searches to find commands that are entered without paths.

The default search path includes the current directory, C:, and several other directories specified in the standard Startup-sequence. You can add other directories in which you keep frequently-used programs by using the PATH command or by using multiple assignments with the ASSIGN command. There is, however, a significant difference between these two methods. Directories added to the search path with the PATH command are local to the Shell in which you added them and to any sub-Shells launched from that Shell. Directories added through multiple assignments with the ASSIGN command are global to the whole system.

When you enter something in the Shell, AmigaDOS looks through the directories in the search pth for a command of that name. It searches the directories in the order they appear in the path until it either finds the command or reaches the end of the path list. When a command cannot be found in any of the search path directories, the Shell displays an Unknown command message, as illustrated in Figure 3-2.

Search Path
Note
AmigaDOS uses the search path to find commands only. You must include a full path to any files referred to in a command's arguments.

Current Directory

The current directory is the Shell's current location in the filing system hierarchy, similar to the Workbench's current window. The name of the current directory is displayed in the default Shell prompt so that you always known where you are. The following properties apply to the current directory:

  • Each Shell has its own independent current directory.
  • A Shell has only one current directory.
  • The current directory is always the first directory in the search path.
  • The path up to and including the current directory is assumed and does not need be included in a path to a particular command that is within the current directory.
  • The current directory is the default directory, the directory on which a command operates, if no other directory is specified.

Changing the current directory, like adding directories to the search path, is a way to reduce the amount of typing necessary to specify a command. Often you need to perform several operations within a certain directory, such as copying, renaming, and deleting files. You can avoid entering the full path for each file by changing the current directory to that directory in which most of the files are located.

Types of Commands

AmigaDOS has both disk-based and internal commands.

Disk-based commands must be loaded from a disk before execution. On systems with hard disks, the disk-based commands are always accessible to the system since they are automatically loaded when invoked. On a floppy-only system, these commands are read from a floppy disk that must be inserted whenever they are called.

Internal commands reside in the Shell, which is in ROM (Read Only Memory). The system accesses internal commands immediately.

Some AmigaDOS commands are essentially the same as menu items or programs on the Workbench. These commands and the corresponding Workbench equivalent are shown in the following table:

Command Function Workbench Counterpart
CD Change the current directory Select another window/icon
COPY Copy a file, directory or disk Copy menu item
DATE Set the correct date and time Prefs/Time editor
DELETE Delete a file or directory Delete menu item
DIR Show files in a directory Show All Files menu item
DISKCOPY Copy a disk Copy menu item
ENDSHELL Close a Shell window Select Shell window close gadget
FORMAT Format a disk Format Disk menu item
INFO Show information on all disks Observe disk window title bars

AmigaDOS Command Structure

Every AmigaDOS command has a specific format and syntax that must be used for the system to accept and act on the command. The general rules for working with AmigaDOS commands are few, but absolute:

  • A legal command or program name must appear first on the command line. The full path to the command is not necessary if the command is in a directory on the search path.
  • Arguments are separated from the command and from each other by spaces; a single space is sufficient, but additional spaces are allowed. No punctuation, other than that specifically needed in the command, should be used.
  • AmigaDOS is not case-sensitive. Any mixture of upper and lower case can be used on the command line, however, case is ignored. Capitalization given in file and directory names is preserved.
  • Except where noted, when a path or string argument contains a space, the entire path or string must be enclosed in double quotation marks ("). For example:
1> ECHO command TO Adisk:Text/Comment
1> ECHO "A comment" TO "My Disk:Text/Comment"
  • The maximum length of a standard Shell command line is 512 characters.

A sample of the structure of an AmigaDOS command line is illustrated in Figure 3-3. It consists of the COPY command followed by two arguments.

Example Command Line

An argument is an additional piece of information the command uses, such as a file name or option. Command arguments are similar to icon Tool Types on the Workbench. Depending on the command, arguments can be optional ir required. Figure 3-3 illustrates the following points about arguments.

  • Keywords for AmigaDOS commands are generally full words or simple abbreviations, in this example, FROM and TO.
  • An argument can consist of more than one term; in the example, a file name argument accepts two names at the same time: Screenmode and Screenmode.info.
  • Some arguments have an identifying keyword, which can be optional or required.
  • When optional keywords are omitted in a multiple-argument command, the arguments must appear in the order shown by the command template.

Special AmigaDOS Characters

There are several characters that have special meanings when used in AmigaDOS. The functions of special characters include the following:

  • Specifying paths
  • Pattern matching
  • Redirecting command input and output

It is important when using AmigaDOS to remember the various special functions that characters can have. Note that in different contexts the same character can have different effects or have no special effect. If a command that appears correct produces unexpected results, check to see if any character in the command has a special function.

Command Line Characters

The colon and slash characters are reserved by AmigaDOS for specifying paths. In file requesters, on the command line, or in scripts these characters are used only to separate components on the path line.

Colon (:)

Colons are used to designate device names (DF0:), volume names (Workbench:), and assigned directories (SYS:). There are no spaces before the colon, unless it is the first character in the path, or between the colon and subsequent file or directory names in a path. Used by itself, the colon represents the root directory of the current volume. The following are examples of legal uses of the colon:

1> DIR DEVS:
1> DIR DF0:Pictures
1> DIR :Prefs
1> DIR :

Slash (/)

Slashes are used within paths to separate directories and file names. For example:

1> LIST Reports/Salesreps/Eastern

The three directory levels are separated by slashes; this example lists the Eastern subdirectory.

Entering a single slash moves the current directory structure up one level. For example, if Reports/Salesreps/Eastern is the current path, entering the following:

1> CD /

changes the directory path to Report/Salesreps. Using two slashes moves upt two levels, and so on.

Double quotation mark (")

The double quotation marks by itself does not have any special meaning. However, you may occasionally need to use double quotation marks around a command argument for the command to work properly. Since AmigaDOS uses spaces as an argument separator, you must enclose an argument (such as path) that contains spaces in double quotation marks to keep the Shell from interpreting the parts of the argument as separate arguments. For example, the following is incorrect:

1> COPY Ram Disk:foo TO SYS:Otherdir

It produces an error message because there is a space in the path. The command indicates that there are two items to be copied, when only one is intended. Enclosing the path in quotation marks forces it to be treated as a single argument:

1> COPY "Ram Disk:foo" TO SYS:Otherdir

Using double quotation marks with nothing between them is a quick way to reference the current directory. For example:

1> COPY DF0:public.library TO ""

If the current directory is LIBS:, the public.library file is copied there.

Plus (+)

The plus sign, when entered with the RUN command, concatenates several commands entered on subsequent lines into a single command line. For further information and examples, see the RUN command in Chapter 6.

Question mark (?)

One of the special uses of the question mark is to display a command's template. The template is an online reminder of the command's arguments. To display a specific command's template, enter the command name followed by a space and then the question mark, with no other arguments:

1> TYPE ?
FROM/A/M, TO/K, OPT/K, HEX/S, NUMBER/S:

The Shell displays the template. It also allows you to enter the arguments for the command with which you have used the question mark. Enter arguments for the command after the colon. Be sure to enter only the arguments and keywords needed before pressing Return.

Pattern Matching

You can work on several files or directories with one command using pattern matching. Special wildcard characters are used in command arguments to match characters in the file names. For example, use a wildcard character in a single command for copying or renaming all the files beginning with a specific letter, ending with the same extension, or residing in the same directory.

Wildcard Characters

The following list shows each wildcard character and the type of match it makes. In the list, a <p> indicates that either a single or multiple character string immediately adjacent to the wildcard is matched. To match a literal wildcard character, you must escape its wildcard meaning by prefacing it with an apostrophe ('). For example, '?, matches ?, and '' (two single apostrophes) matches '.

? Matches any single character.
#<p> Matches zero or more occurrences of <p>.
<p1>|<p2> Matches if either <p1> or <p2> matches.
~<p> Matches everything but <p>.
(<p1><p2>...) Parentheses group items together.
[<p>-<p>] Square brackets delimit a character range.
% Matches the null string (no characters).
'<p> When <p> is wildcard character, matches that character.

The following examples indicate the matches that can be made using the entry in the left column.

A?B Matches any three character names beginning with A and ending with B, such as AcB, AzB, and a3b.
A#BC Matches any name beginning with A, ending with C, and having any number of Bs in between, such as AC, ABC, ABBC, ABBBC.
ABC#? Matches any name beginning with ABC, regardless of what follows, such as ABCD, ABCDEF.info, or ABCXYZ.
#?XYZ Matches any name ending in XYZ, regardless of what precedes it, such as ABCXYZ and ABCDEFXYZ.
A(B|C)D Matches ABD or ACD.
~(XYZ) Matches anything but XYZ.
~(#?XYZ) Matches anything not ending in XYZ.
A#(BC) Matches any name beginning with A followed by any number of BC combinations, such as ABC, ABCBC, and ABCBCBC.
A(B|D|%)#C Matches ABC, ADC, AC (% is the null string), ABCC, ADCC, ACCC, and so forth.
[A-D]#? Matches any name beginning with A, B, C, or D.
#?XYZ'? Matches any name ending with XYZ?

The combination of #? matches any characters and is used most often. #? is equivalent to the * wildcard used by other computer systems. For example, to delete all the .info files in the Picture directory, enter:

1> DELETE Picture/#?.info
Caution
Be careful not to accidentally delete the contents of a disk when using #?.

Redirection

Redirection can change input or output to a specific file or device (such as printer, modem, or logical device). When working in the Shell, the keyboard is the source of command input a nd the current Shell window is the destination for output. You can redirect input and output using the left angle bracket, right angle bracket, and asterisk characters.

Angle Brackets

A redirection argument consists of either the < or > symbol followed by a file name or device name. The angle bracket must be preceded by a space, but no trailing space is necessary.

For some commands, the redirection characters can replace the keywords TO and FROM, depending on the command's syntax.

You can only redirect input or output on the command line in which the redirection characters appear. AmigaDOS applies the default input and output sources for any subsequent commands without redirection.

Right Angle Bracket (>)

The right angle bracket redirects the console output of a command to the destination pointed to by the bracket. The console output is the text that the command prints in the Shell window when executed. For example:

1> DIR >Testfile DF0:

sends a directory listing of DF0: to a file in the current directory called Testfile. Testfile is created if it does not already exist and it contains the directory listing as ASCII text. The directory listing is not displayed on the screen.

Only the console output of a command is redirected, not the data on which the command works. For example:

1> COPY >Log Picdir TO PicsArchive: ALL

copies all the files in the Picdir directory to the PicsArchive disk, sending a list of the copied file names to the Log file.

Left Angle Bracket (<)

To change the source of a command's input from the keyboard to a file, use the < symbol. However, a question mark (?) must also be used as a separate argument on the command line. The question mark instructs the command to accept input; it is not a wildcard character in this context. The following example creates a file and then uses the contents of the file as the argument for a command:

1> ECHO tomorrow TO Datefile
1> DATE ? <Datefile

The ECHO command creates a file called Datefile containing the word "tomorrow". The DATE command accepts the contents of Datefile (the word "Tomorrow") as if it were entered at the keyboard. This sets the system date 24 hours ahead.

Double Right Angle Brackets (>>)

Redirect output and append material to an existing file using two output symbols (>>) with no spaces between them. For example:

1> Postscript >>Laser/Letter

executes the program Postscript, adding its output to the end of the Laser/Letter file.

Asterisk (*)

An asterisk refers to the current Shell window. However, to avoid confusion with other use of the asterisk, we recommend using CONSOLE:, which is the synonym for *. The asterisk can be used as a FROM or TO argument or as a redirection file name (the source of input or the output destination).

Pressing Ctrl+\ restores input/output to the default source. For example:

1> COPY * TO Screenfile

or

1> COPY CONSOLE: TO Screenfile

copies all subsequent text typed in the current window to the file called Screenfile until you press Ctrl+\.

Ctrl+\ is also used to close a Shell window. Be careful not to press this key combination twice when you want to end the redirection since it also closes the Shell window.

Running Programs

Most programs can be run from both the Workbench and the Shell. To run a program from the Shell, you usually enter the program name at the Shell prompt. (If the program file is not in the search path, you must specify the complete path to the file.) This tells AmigaDOS to load and execute the program.

Most programs allow you to specify additional information on the command line after the program name, such as the name of a file to load or startup options. These additional items are ist arguments. Refer to a program's documentation to determine the arguments it allows and how they should be entered.

For example:

1> MEmacs

loads and runs the MEmacs editor. Adding an argument:

1> MEmacs S:User-startup

loads and runs MEmacs, automatically opening the User-startup file in the S: directory as the file to begin editing.

1> CLOCK WIDTH 200 HEIGHT 100 SECONDS

loads the Clock with a specified size of 200 pixels by 100 pixels and the SECONDS option turned on.

Often this argument-passing ability is provided as a convenience, allowing you to specify directly on the command line what might otherwise require several menu operations. However, many programs, especially those that can only be run from a Shell, require that file names or other arguments be specified on the command line with the program name.

Running Programs in the Background

Another way to enter a program name is with the RUN command. RUN loads and runs a program in the background. The Shell prompt returns after the program is opened.

For example, entering:

1> MEmacs

opens the MEmacs editor, but you cannot enter any additional commands or close the Shell window until you exit MEmacs.

However, entering:

1> RUN MEmacs

opens the MEmacs editor and returns the Shell prompt so that you can enter additional commands.

When a program is invoked with RUN, a process number is assigned to it and a message indicating the new process number is displayed, such as [CLI 2] .

Any output that the program generates appears in the originating Shell window.

You cannot close the Shell window if any programs launched from that window are still running. For example, if you open MEmacs through the Shell, you cannot close the Shell window until you exit MEmacs. Avoid this by using the NIL: device. See Chapter 8 for an example.

Refining Your AmigaDOS Environment

The following tips help you to set up your AmigaDOS environment to suit your particular needs.

Customize your Shell prompt
Changing the color, for example, of the prompt string with escape codes makes the prompt easier to distinguished from the rest of the command line and the output that your commands produce. This command line and the output that your commands produce. This helps you keep track of the process number and current directory that are normally part of the prompt. For more information on how to change your Shell prompt, see the PROMPT command in Chapter 6 and the example in Chapter 8.
Create a logical directory structure and use meaningful names
Because gaining access to something requires knowing where it is, you should organize your disks and directories in a logical way, with names that reflect their contents. However, do not create directory structures that are heavily nested without good reason.
Avoid using spaces and other special characters in names
Characters with special meaning in AmigaDOS, such as # and ~, are allowed in names, but can cause problems when used on the command line. Use a period (.), underscore (_), or capital letters instead of spaces to separate words in a name: "Anim.file," "Anim_file," or "NimFile" rather than "Anim file."
Name related files consistently
Giving related file names a common extension or sequential numbering simplifies using pattern matching when processing files.
Use assigned names in paths
Assigned names allow you to type a short, easy-to-remember name rather than a long path. For example, it is quicker to type ENVARC: than SYS:Prefs/Env-archive. Make your own assigned names for directories you use often and for deeply nested directories.
Extend the search path
If you have a variety of often-used commands or programs, adding their directories to the search path with PATH or ASSIGN makes accessing them easier.
Experiment
The best way to learn how AmigaDOS works is to experiment. Provided that you use caution with potentially destructive commands, such as pattern-matching DELETEs, you can experiment freely.