Thursday 14 April 2016

Command Syntax

Each DOS command has a mandatory part and some have an optional part. Presented here,
the mandatory parts will be shown in bold CAPITAL LETTERS and the optional parts in lower case.
For example,
DIR d:pathname\filename.ext /p /w
is the complete command for a disk directory. Note that only DIR is necessary.
You may note the term pathname in the above command. The pathname is the full descriptive name to any location on the disk. It includes the names of all directories (see subdirectories later in this section).
In some commands you may use wildcards. A wildcard, like the joker in a card deck, can stand for any character or group of characters.
The ? represents any single character: FILE? = FILE1 or FILED etc.
The * represents any group of characters:
*.* = Any file and extension
Use caution with wildcards. They can be dangerous with commands that do things like erase files.  Also,  in  somcases  a  wildcard  formulation  can  be  misleading.  The  combination AP*EX.COM does not mean all files that start with AP and end with EX in their root name and with a COM extension. It means all files starting with AP and having an extension of COM. The EX is meaningless as it is ignored because of the asterisk.

Disk Directory
To see a listing of what is on a disk, issue the DIRectory command.
It comes with several options (shown are the most useful, not all).

DIR d:filename.ext /p /w
DIR alone will show the complete directory. With the optional filename, DIR will try to find just that file.
•    The /p option causes a pause when the screen fills.
•    The /w option yields a full 80-column display of just the filenames.
There are other options for sorting the listing and displaying the contents of lower-level directories. Now we'll see what would happen when you type DIR at the prompt.



Note several things here.
•    DIR tells you what files are on the disk, how big they are, and when they were created.
•      DIR also tells how many files total are in the list, how much space those take and what free space remains.

Three Simple Commands
CLS Clears the screen and puts the cursor in the home (upper left) position.
VER Shows the DOS version number on the video display. You are shown the one-digit version and two-digit revision:
MS-DOS Version 6.00
VOL d: Displays a volume label, if one exists. The label is a name you have given to the disk when it was formatted. It is used for identification purposes. (The serial number is put on the disk by the FORMAT utility.)
Volume in drive C is HANDBOOK Volume Serial Number is 2C35-16F9

Date and Time
These two commands show and/or set the system date and time.
Early computers relied on you to set the DOS clock during the boot process. In short order peripheral makers came out with clock cards that, with the help of a battery, kept a clock going and, with the help of a program in AUTOEXEC.BAT, loaded the time into DOS for you during boot. New computers have the clock built-in and do not require a program to load the time.
If your clock battery fails, the default values will be 1-1-80 for the date and 00:00:00.00 for time. Now and again you will see files with a create date of 1/1/80; they were created on a system where the clock has failed and DOS has used its default value.
For the DATE command you can enter the date as month/day/year with hyphens or slashes, i.e., 3/1/94 or 3-1-94 are acceptable dates.
Do not enter the day of the week, even though it shows on the screen. The computer will calculate it for you. A two digit year assumes dates between 1980 and 1999. In 2000 you will have to start putting in all four digits.



The format for DATE is:
DATE <date>
On early computers the time setting required a 24-hour clock, i.e., any time after noon had to have 12 added to it, for example 3:00 pm had to be entered as 15:00. While the TIME command will still respond to this type of time, you may not also enter 3:00p and the computer is smart enough to know you mean 15:00.
The format for TIME is:
TIME <time>
On most computers these commands will change the permanent clock settings as well as changing the date/time in DOS.
Disks straight out of the package need to be formatted, that is have tracks and sectors defined so
DOS can find programs and data on the disk.
The command syntax is below (only the most useful options are shown).
FORMAT  d: /s /u where
•    d: defines the disk that will be formatted
•    /s puts the DOS system on disk to make it bootable
•    /u specifies an unconditional format (can't unformat the disk) An example:
Problem: Format the disk in drive A: without UNFORMAT information.
Answer: The proper command is: C>FORMAT A: /U


In order, you are asked to confirm a disk is present for formatting, then told to what capacity the disk will be formatted (press Control-C to stop the format if this is not correct), then you are given a report on format progress. At the end you are asked for a volume label (optional) and then given a report on the success of the format in terms of the number of bytes on the disk. A serial number is assigned by DOS. It is based on system time and will likely never be the same on two individual disks.



Additional  Comments
Some microcomputers have 1.2 megabyte 5.25" disk drives. There is the temptation to use
360 kilobyte disks in those drives; don't do it. The track width is smaller and if you then put the
360K disks into a 360K drive, they may not work properly. Likewise, you cannot use the high density floppy disks themselves in 360K drives. The magnetic properties of the disk are such that the 360K drives won't format them.
With the introduction of 3.5" drives, higher versions of DOS are required to correctly support the new formats. The 3.5" drives come in two sizes: 720K and 1.4MB.
Unlike the 1.2MB/360K drives disks, it is possible to format to 720K in a 1.4MB 3.5" drive. All you have to do is tell the FORMAT command the track/sector combination you need:
FORMAT  A: /F:720 (this tells DOS to format the disk in drive A: to 720K)
Not all versions of DOS support higher capacity disks. For example, DOS 3.2 introduced support for 3.5-inch disks, but only at 720K format. In order to format a 3.5-inch disk at 1.44MB you will need DOS 3.3 or later.

23.1  Checking the Disk
Now and again it is useful to check the integrity of the disk directory and file allocation
table (FAT). The FAT is so important to the disk that there are two copies of it on each disk. The CHKDSK program does this for you. The basic format is:
CHKDSK d:filename.ext /f /v
Using the filename causes it to be checked for continuity (i.e., being stored on contiguous sectors on the disk for more efficient access).
•    /f tells DOS to automatically fix the FAT and other problems
•    /v is a verbose mode that shows progress as disk checking is taking place
Example:


Only use the version of CHKDSK that came with your version of of DOS. Crossing versions can cause great damage to a disk.

23.2  Backing Up a Floppy Disk
Floppy disks wear out after several hundred spin hours. Well before then you should have
made a copy of the disk to preserve the integrity of its contents. You can, of course FORMAT  and then COPY *.* to accomplish this. There is a quicker way however:
DISKCOPY  d1: d2:
If you do not give drive specifications, the utility will ask for them.
All information on the target disk will be destroyed, and DISKCOPY will format the target if it is found blank. Be careful, it's easy to destroy data by putting the disks in backwards!



Problem: Copy disk A: to B:. Issue the proper command.
Answer: C:\>DISKCOPY A: B:

23.3  Erasing Files
Files you no longer need should be deleted from your disk to make room for more current
files. Use the ERASE (DELete) command for this:
ERASE d:FILENAME.ext or
DEL d:FILENAME.ext
Be careful, typographic errors in this command can bring disaster!
You are allowed to delete all files on a disk with the wildcard * (ERASE *.*), but DOS will question you.
Recovery BEFORE writing anything else to disk is possible. An UNDELETE utility started shipping with DOS 5.0. Before that commercial utilities were available.

23.4  Renaming  Files
For whatever reason, you may need to change the name of a file on your disk. (Usually this
is the case when you want to change a backup file to another name in order to return it to active status.)
Use this format:
REName d:OLDNAME.ext NEWNAME.ext
Wildcards are allowed, but can cause trouble if you are not careful.
The rename command will give you an error message if NEWNAME exists.

23.5  Copying Files
The COPY command is a very powerful command within DOS. With it you can create
duplicates of individual files, join several files into one, and even use your computer like a simple typewriter by "copying" from the device named CON: to the device named PRN (inefficient, but OK for short notes).
Copying one file to another (copies from filename1 to filename2):
COPY d1:FILENAME1.ext d2:filename2.ext/v
/v option verifies the copy as it takes place. This adds confidence at the price of slower operation. There are other options not shown here. Wildcards are allowed.

For example,
C:\>COPY ADDRS.LST B: Copies the single file ADDRS.LST from C: to B:.
C:\>COPY *.* B:/V Copies all files on C: to the disk in B: and verifies the information is it is being written.
C:\>COPY ADDRS.LST Yields an error message. Can't copy a file to itself.
C:\>COPY B:*.* Copies all files from drive B: to drive C:. (If a destination is not specified, the default drive and directory is used.)

Copy can also be used to concatenate (join) several files by using the following form:

COPY d1:FILENAME1.ext+d2:FILENAME2.ext+... d0:filename0.ext/v

The options are the same as the previous version of the copy command.
All specified filenames (#1, #2, etc.) will be copied and joined into filename0. If no filename0 is specified, the first source file named will be used.
Wildcards are dangerous with this command.



Example:
Contents of FILE1: This is file number one Contents of FILE2: This is file number two C:\>COPY FILE1+FILE2 FILE3

Contents of FILE3: This is file number oneThis is file number two
The COPY command can be used to create text files by copying from device CON: to a file. The procedure is outlined in the text of the example below.
C:\>COPY CON: TEXTFILE

This is the text to go into the text file being created. Each line is typed to the screen and it is being saved into a buffer for later transfer to the file TEXTFILE. Each line may be corrected as it is typed, but cannot be changed after it is terminated by the carriage return. Also, if you happen to type beyond column 80 on the screen, you cannot correct anything on the line above. Each line must be terminated by a carriage return (the enter key). You signal you are finished by typing a Control-Z, the symbol for end-of-file, followed by Return. ^Z
1 File(s) copied

XCOPY
For copying multiple files the XCOPY command can be a powerful ally. As its name
implies, the command performs extended copies.
Its format (with only often-used options) is shown here:
XCOPY d1:PATH1 d2:path2 /a /m /s /v
Like the COPY command, XCOPY can take a single drive/path designator in which case files from that destination will be copied into the current directory. Some options:
/A Copy only files with archive bit set; do not reset archive bit.
/M Copy only files with archive bit set; reset archive bit.
/S Copy subdirectories as well unless they are empty.
/V Verify copied files as they are written.
You can copy an entire hard disk to another disk with a single command:
XCOPY C: D: /S
The contents of drive C: will be copied to drive D: a file at a time, with the subdirectory structure intact.
You can use the same technique to back up a hard disk to a removable disk (e.g., Bernoulli or other removable media - don't use floppies). Note the /M option above. When DOS writes a file to the disk it sets an archive bit in the disk directory to indicate the file has been somehow changed (it's possible to write a file and not change it but DOS just assumes changes were made). The /M option for XCOPY can take advantage of this.

To proceed:
1) Make a full backup first.
Use the ~ATTRIB~ command to set all archive bits to ON:
C:\>ATTRIB +A *.* /S
Use XCOPY to copy all files and directories, turning all archive bits OFF in the process (assumes removable media is G:):
C:\>XCOPY C:\ G: /M /S
2) On a regular basis use the XCOPY command to perform an incremental backup:
C:\>XCOPY  C:\ G: /M /S
The backup on drive G: will be an image of the file and directory structure on drive C:. The
incremental backup makes certain the image is current.
Periodically, in order to purge deleted files from the backup you should start over at #1 above and a clean backup disk.



Typing a File
Any text file saved in ASCII character format can be easily seen on your video display. Use
the type command:
TYPE d:FILENAME.ext

All characters in the file will be displayed on the screen, including any control characters, sometimes resulting in interesting displays.
Any control-I characters found will be interpreted as a tab, and spaces will be added to get the cursor over to the next 8-character boundary; some output may appear as tables. Control-Z will cause output to stop.

Attempting to TYPE a .COM or .EXE file will result in garbage on the screen, and should generally be avoided.

No comments:

Post a Comment

Popular Posts