]> wirehaze git hosting - MS-DOS.git/blob - v2.0/source/UTILITY.txt

wirehaze git hosting

Fix typo in readme.pt-br.md
[MS-DOS.git] / v2.0 / source / UTILITY.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 MS-DOS 2.0
20
21 Utility Extensions
22 \f
23
24
25
26
27
28
29
30 The following notation is used below:
31
32 [item] item is optional.
33 item* item is repeated 0 or more times.
34 item+ item is repeated 1 or more times.
35 {item1 | item2}
36 item1 is present or item 2 is present but
37 not both.
38 <object> indicates a syntactic variable.
39 \f
40
41 COMMAND invokation
42
43 COMMAND [[<drive>:]<path>] [<cttydev>] [-D] [-P] [-C <string>]
44
45 -P If present COMMAND will be permanent, otherwise
46 this is a transient command.
47
48 -D If present COMMAND will not prompt for DATE and
49 TIME when it comes up.
50
51 d: Specifies device where command will look for
52 COMMAND.COM current default drive if absent.
53
54 <Path> Specifies a directory on device d: root
55 directory if absent.
56
57 <cttydev> Name of the CTTY device. /DEV/CON if absent
58 and command is permanent. The /DEV/ may be left
59 off if AVAILDEV is TRUE (see sysinit doc).
60
61 -C <string> If present -C must be the last switch.
62 This causes COMMAND to try to execute the string
63 as if the user had typed it at the standard input.
64 COMMAND executes this single command string and
65 then exits. If the -P switch is present it is
66 ignored (can't have a single command, permanent
67 COMMAND). NOTE: ALL of the text on the command
68 line after the -C is just passed on. It is not
69 processed for more arguments, this is why -C must
70 be last.
71
72 COMMAND extensions
73
74 IF <condition> <command>
75
76 where <condition> is one of the following:
77
78 ERRORLEVEL <number>
79 true if and only if the previous program EXECed by
80 COMMAND had an exit code of <number> or higher.
81
82 <string1> == <string2>
83 true if and only if <string1> and <string2> are
84 identical after parameter substitution. Strings
85 may not have embedded delimiters.
86
87 EXIST <filename>
88 true if and only if <filename> exists.
89
90 NOT <condition>
91 true if and only if <condition> is false.
92
93 The IF statement allows conditional execution of commands.
94 When the <condition> is true, then the <command> is
95 executed otherwise, the <command> is skipped.
96
97 Examples:
98
99 IF not exist /tmp/foo ECHO Can't find file /tmp/foo
100
101 IF $1x == x ECHO Need at least one parameter
102
103 IF NOT ERRORLEVEL 3 LINK $1,,;
104
105
106 FOR %%<c> IN <set> DO <command>
107
108 <c> can be any character but 0,1,2,3,..,9 (so there is no
109 confusion with the %0 - %9 batch parameters).
110
111 <set> is ( <item>* )
112
113 The %%<c> variable is sequentially set to each member of
114 <set> and then <command> is evaluated. If a member of
115 <set> is an expression involving * and/or ?, then the
116 variable is set to each matching pattern from disk. In
117 this case only one such <item> may be in the set, any
118 <item>s after the first are ignored.
119
120 Example:
121
122 FOR %%f IN ( *.ASM ) DO MASM %%f;
123
124 for %%f in (FOO BAR BLECH) do REM %%f to you
125
126 NOTE: The '%%' is needed so that after Batch parameter
127 (%0 - %9) processing is done, there is one '%' left.
128 If only '%f' were there, the batch parameter processor
129 would see the '%' then look at 'f', decide that '%f'
130 was an error (bad parameter reference) and throw out
131 the '%f' so that FOR would never see it. If the FOR
132 is NOT in a batch file, then only ONE '%' should be
133 used.
134 \f
135
136 SHIFT
137
138 Currently, command files are limited to handling 10
139 parameters: %0 through %9. To allow access to more than
140 these, the command SHIFT will perform a 'pop' of the
141 command line parameters:
142
143 if %0 = "foo"
144 %1 = "bar"
145 %2 = "blech"
146 %3...%9 are empty
147
148 then a SHIFT will result in the following:
149
150 %0 = "bar"
151 %1 = "blech"
152 %2...%9 are empty
153
154 If there are more than 10 parameters given on a command
155 line, then the those that appear after the 10th (%9) will
156 be shifted one at a time into %9 by successive shifts.
157
158 :<label>
159
160 This is essentially a no-op. It defines a label in the
161 batch file for a subsequent GOTO. It may also be used to
162 put comment lines in batch files since all lines that
163 start with ':' are ignored.
164
165 GOTO <label>
166
167 Causes commands to be taken from the batch file beginning
168 with the line after the <label> definition. If no label
169 has been defined, the current batch file will terminate.
170
171 Example:
172
173 :foo
174 REM looping...
175 GOTO foo
176
177 will produce a infinite sequence of messages:
178 'REM looping...'
179
180 NOTE: Labels are case insensitive, :FOO == :foo == :Foo
181 \f
182
183 ECHO [{ON | OFF | <message>}]
184
185 Normally, commands in a BATCH file are echoed onto the
186 standard output as they are seen by COMMAND. ECHO OFF
187 turns off this feature. ECHO ON turns echoing back on.
188 If ON or OFF is not specified and there is text following
189 the command, that text (a message) is echoed to standard
190 output. If there are no arguments at all, the current
191 setting of echo (on or off) is echoed to the standard
192 output in the form:
193
194 ECHO is xxx
195
196 Where xxx is "on" or "off".
197
198 Redirection of standard input/standard output.
199
200 Programs that read from the keyboard and write to the
201 screen are said to be doing I/O to the standard input and
202 standard output. Using any of the following will result
203 in I/O to these standard devices:
204
205 Writing to default handles 1 / read from default
206 handle 0.
207
208 Doing byte I/O using system calls 1, 2, 6-12.
209
210 These standard devices may be redirected to/from files by
211 the following in command line arguments:
212
213 > <filename>
214 causes <filename> to be created (or truncated to
215 zero length) and then assigns standard output to
216 that file. All output from the command will be
217 placed in the file.
218
219 < <filename>
220 causes standard input to be assigned to
221 <filename>. All input to the command will come
222 from this file. If end-of-file is reached, then
223 system calls 1, 2, 6-12 will return ^Z , while
224 reading from handle 0 will return zero characters.
225
226 >> <filename>
227 causes <filename> to be opened (created if
228 necessary) and positions the write pointer at the
229 end of the file so that all output will be
230 appended to the file.
231
232 Note that the above will not appear in the command line
233 that the program being invoked sees.
234
235 Examples:
236
237 DIR *.ASM > FOO.LST
238 Sends the output of the dir command to the file
239 FOO.LST.
240 \f
241
242 FOR %0 IN (*.ASM) DO MASM %0; >>ERRS.LST
243 Sends all error output from assembling every .ASM file
244 into the file ERRS.LST.
245
246 Piping of standard I/O
247
248 It is often useful for the output of one program to be
249 sent as input to another program. A typical case is a
250 program that produces columnar output that must later be
251 sorted.
252
253 The pipe feature allows this to occur naturally is the
254 programs do all of their I/O to the standard devices.
255
256 For example, if we had a program SORT that read all of
257 it's standard input, sorted it and then wrote it to the
258 standard output, then we could get a sorted directory
259 listing as follows:
260
261 DIR | SORT
262
263 The | would cause all standard output generated by the
264 left-hand command to be sent to the standard input of the
265 right-hand command.
266
267 If we wanted the sorted directory to be sent to a file, we
268 type:
269
270 DIR | SORT >FILE
271
272 and away it goes.
273
274 The piping feature is implemented as sequential execution
275 of the procedures with redirection to and from temporary
276 files. In the example above, the following would be an
277 exact equivalent:
278
279 DIR >/tmp/std1
280 SORT </tmp/std1 >FILE
281
282 \f
283
284 The pipe is not a real pipe but rather a quasi-pipe
285 that uses temporary files to hold the input and output as
286 it sequentially executes the elements of the pipe. These
287 files are created in the current directory, of the current
288 drive and have the form %PIPEx%.$$$, where x will be 1 or
289 2. This means that any program that runs in the pipe must
290 be sure to restore the current directory and drive if it
291 has changed them, otherwise the pipe files will be lost.
292
293
294 VER
295 Prints DOS version number.
296
297 VOL [<drive>:]
298 Prints the volume ID of the disk in drive d:. No d: does
299 default drive.
300
301 CHDIR [{<drive>: | <path>}]
302 Change directory, or print current. directory.If no
303 argument is given, the current directory on the default
304 drive is printed. If d: alone is given, the durrent
305 directory of drive d is printed. Otherwise the current
306 directory is set to path.
307
308 NOTE:"CD" is accepted as an abbreviation.
309
310 MKDIR <path> - Make a directory.
311 "MD" is accepted as an abbreviation.
312
313 RMDIR <path> - Remove a directory.
314 "RD" is accepted as an abbreviation.
315 The directory must be empty except for
316 '.' and '..'.
317
318 <path> - A standard XENIX style path with the optional
319 addition of a drive spec:
320
321 A:/FOO/BAR Full path
322 /FOO/BAR Full path, current drive
323 FOO/BAR Current dir relative
324 A:FOO/BAR " " "
325
326 VERIFY [{ON | OFF}]
327 Select/deselect verify after write mode. This supliments
328 the V switch to the COPY command. Once turned ON, it
329 stays on until some program changes it (via the set verify
330 system call) or the VERIFY OFF command is given. If no
331 argument is given, the current setting of VERIFY is
332 printed to the standard output in the form:
333
334 VERIFY is xxx
335
336 Where xxx is "on" or "off".
337
338 PATH [<path>{;<path>}*]
339 Set command search paths. This allows users to set
340 directories that should be searched for external commands
341 after a search of the current directory is made. The
342 default value is /bin. In addition there are two special
343 cases: PATH all by itself with no arguments will print
344 the current path. Path with the single argument ';' (ie.
345 "PATH ;") will set the NUL path (no directories other than
346 the current one searched). If no argument is given, the
347 current value of PATH is printed to the standard output in
348 the form:
349
350 PATH=text of path
351 or
352 No path
353
354 NOTE: On IBM systems, the default value of path is No
355 path.
356
357 EXIT
358 For COMMANDs run without the P switch, this causes COMMAND
359 to return. For a normal COMMAND it causes a return to
360 itself.
361
362 BREAK [{ON | OFF}]
363 Like in CONFIG.SYS, "BREAK ON" turns on the Control C
364 check in the DOS function dispatcher. "BREAK OFF" turns
365 it off. If no argument is given the setting of BREAK is
366 printed to the standard output in the form:
367
368 BREAK is xxx
369
370 Where xxx is "on" or "off".
371
372 PROMPT [<prompt-text>]
373 Set the system prompt. MS-DOS prompts are now user
374 settable, all of the text on the command line is taken to
375 be the new prompt. If no text is present the prompt is
376 set to the default prompt. There are meta strings for
377 various special prompts. These are of the form '$c' where
378 c is one of the following:
379
380 $ - The '$' character.
381 t - The time.
382 d - The date.
383 p - The current directory of the default drive.
384 v - The version number.
385 n - The default drive.
386 g - The '>' character.
387 l - The '<' character.
388 b - The '|' character.
389 s - The ' ' character.
390 e - The ESC character.
391 _ - A CR LF sequence.
392
393 EXAMPLE:
394 PROMPT $n:
395 Would set the normal MS-DOS prompt.
396 PROMPT $n>
397 Would det the normal PC-DOS prompt.
398 PROMPT Time = $t$_Date = $d
399 Would set a two line prompt which printed
400 Time = (current time)
401 Date = (current date)
402
403 NOTE: For '$c' sequences, lower case = upper case, and
404 any character not on the above list is mapped to
405 nothing.
406
407 SET (ENVNAME)=(ENVTEXT)
408 Set environment strings. This command inserts strings in
409 COMMAND's environment. For instance:
410
411 SET PROMPT=$n>
412 Duplicates the function of the PROMPT command.
413 SET PATH=p1;p2
414 Duplicates the function of the PATH command.
415 SET foo=bar
416 Puts the string FOO=bar into the environment (note the
417 case mapping of (ENVNAME)).
418
419 NOTE: Environments are very flexible, almost anything can
420 be put into the environment with the SET command; the
421 only requirement is that a single '=' be present in
422 the string.
423
424 CLS
425 Clear screen, causes the ANSI escape sequence ESC[2J to be
426 sent to standard output.
427
428 CTTY /DEV/dev - Change console TTY. For instance:
429
430 CTTY /DEV/AUX
431
432 Would move all command I/O to the AUX port.
433
434 CTTY /DEV/CON
435
436 Would move it back to the normal device. The
437 /dev/ prefix may be left off if AVAILDEV is
438 TRUE (see configuration-file doc).
439
440 COMMAND internal commands take path arguments.
441
442 DIR <path>
443
444 COPY <path> <path>
445
446 DEL(ERASE) <path>
447 If the path is a dir, all files in that dir
448 are deleted.
449 NOTE: The "Are you sure (Y/N)" prompt for DEL and
450 ERASE now uses buffered standard input, so
451 users must type a return after their answer.
452 This gives them the chance to correct if they
453 type 'y' by mistake.
454
455 TYPE <path> (must specify a file)
456
457 \f
458
459
460 FILCOM - compare two files
461
462 The FILCOM program compares two files and produces a log
463 of differences between them. The comparison may be made
464 in two fashions; either on a line-by-line basis, or on a
465 byte-by-byte basis.
466
467 The line-by-line compare will isolate blocks of lines that
468 are different between the two files and will print the
469 blocks from each file. The line-by-line compare is the
470 default when neither of the two files being compared has
471 the extension .EXE, .COM, or .OBJ.
472
473 The byte-by-byte compare will display exactly which bytes
474 are different between the two files. If either file being
475 compared has extension .EXE, .COM, or .OBJ then the files
476 will be compared in byte-by-byte mode.
477 \f
478
479
480 RECOVER - recover files from a trashed disk.
481
482 If a sector on a disk goes bad, you can recover either the
483 file that contained that sector (without the sector) or
484 the entire disk (if the bad sector was in the directory).
485
486 To recover a particular file:
487
488 RECOVER <file-to-recover>
489
490 This will cause the file to be read sector by sector and
491 to be have the bad sector skipped. Note that this implies
492 that the allocation unit containing the bad sector will be
493 read as much as possible. When such a bad sector is
494 found, its containing allocation unit is marked as bad,
495 thus preventing future allocations of that bad sector.
496
497 To recover a particular disk:
498
499 RECOVER <drive-letter>:
500
501 This will cause a scan to be made of the drive's FAT for
502 chains of allocation units (files). A new root directory
503 is then written that has entries of the form FILEnnnn.
504 Each FILEnnnn will point to the head of one of the
505 allocation unit chains.
506
507 If there are more chains than directory entries in the
508 root, RECOVER prints a message and leaves the un-RECOVERED
509 chains in the FAT so that RECOVER can be run again once
510 some room has been made in the ROOT.
511 \f
512
513
514 DEBUG ON MS-DOS 2.0
515
516
517 When 2.0 DEBUG is invoked it sets up a program header
518 atoffset 0 in its program work area. On previous versions it
519 was OK to overwrite this header with impunity: this is true
520 of the default header set up if no <filespec> is given to
521 DEBUG. If DEBUGging a .COM or .EXE file, however, you must be
522 careful not to tamper with the header of the program below
523 address 5CH, to do this will probably result in a crash. It
524 is also important that an attempt is not made to "restart" a
525 program once the "program terminated normally" message is
526 given. The program must be reloaded with the N and L commands
527 in order for it to run properly.
528
529 NEW FEATURES
530
531 The A (Assemble) Command
532
533 FORMAT: A [<address>]
534
535 PURPOSE: To assemble 8086/8087/8088 mnemonics directly into
536 memory.
537
538 o If a syntax error is encountered, DEBUG responds with
539
540 ^ Error
541
542 and redisplays the current assembly address.
543
544 o All numeric values are hexadecimal and may be entered
545 as 1-4 characters.
546
547 o Prefix mnemonics must be entered in front of the opcode
548 to which they refer. They may also be entered on a
549 separate line.
550
551 o The segment override mnemonics are CS:, DS:, ES:, and
552 SS:
553
554 o String manipulation mnemonics must explictly state the
555 string size. For example, the MOVSW must be used to
556 move word strings and MOVSB must be used to move byte
557 strings.
558
559
560 o The mnemonic for the far return is RETF.
561
562 o The assembler will automatically assemble short, near
563 or far jumps and calls depending on byte displacement
564 to the destination address. These may be overridden
565 with the NEAR or FAR prefix. For example:
566
567 0100:0500 JMP 502 ; a 2 byte short jump
568 0100:0502 JMP NEAR 505 ; a 3 byte near jump
569 0100:0505 JMP FAR 50A ; a 5 byte far jump
570
571 The NEAR prefix may be abbreviated to NE but the FAR
572 prefix cannot be abbreviated.
573
574 o DEBUG cannot tell whether some operands refer to a word
575 memory location or a byte memroy location. In this case
576 the data type must be explicity stated with the prefix
577 "WORD PTR" or "BYTE PTR". DEBUG will also except the
578 abbreviations "WO" and "BY". For example:
579
580 NEG BYTE PTR [128]
581 DEC WO [SI]
582
583 o DEBUG also cannot tell whether an operand refers to a
584 memory location or to an immediate operand. DEBUG uses
585 the common convention that operands enclosed in square
586 brackets refer to memory. For example:
587
588 MOV AX,21 ;Load AX with 21H
589 MOV AX,[21] ;Load AX with the contents
590 ;of memory location 21H
591
592 o Two popular pseudo-instructions have also been included.
593 The DB opcode will assemble byte values directly into
594 memory. The DW opcode will assemble word values directly
595 into memory. For example:
596
597 DB 1,2,3,4,"THIS IS AN EXAMPLE"
598 DB 'THIS IS A QUOTE: "'
599 DB "THIS IS A QUOTE: '"
600
601 DW 1000,2000,3000,"BACH"
602
603
604 o All forms of the register indirect commands are supported.
605 For example:
606
607 ADD BX,34[BP+2].[SI-1]
608 POP [BP+DI]
609 PUSH [SI]
610
611 o All opcode synonyms are supported, For example:
612
613 LOOPZ 100
614 LOOPE 100
615
616 JA 200
617 JNBE 200
618
619 o For 8087 opcodes the WAIT or FWAIT prefix must be
620 explictly specified. For example:
621
622 FWAIT FADD ST,ST(3) ; This lines will assemble
623 ; a FWAIT prefix
624
625 FLD TBYTE PTR [BX] ; This line will not
626 \f
627
628
629 FORMAT enhancements
630
631 FORMAT will now install volume id's during the format
632 process. DIR and CHKDSK will display these volume id's.
633
634 User programs can read the volume id on a particular drive
635 by doing a 'search next' with the volume id attribute. It
636 is impossible, using normal DOS calls, to delete a volume
637 id or to create another one. The only way to create a
638 volume id is to reformat the disk.
639
640 NOTE: On IBM systems the V switch must be given to FORMAT
641 to have it do Volume IDs.
642
643 \f
644
645
646 CHKDSK FOR MS-DOS 2.0
647
648
649 MS-DOS 2.0 has a tree structured directory scheme which
650 did not exist on previous versions of MS-DOS. As a result
651 CHKDSK is a much more complex program than in previous
652 versions since it must perform a tree traversal to find all of
653 the files on a given disk. It employes a depth first
654 traversal in order to accomplish this.
655
656 Previous versions of CHKDSK automatically "fixed"
657 disks (regardless of whether it was appropriate). CHKDSK 2.00
658 run normally will not alter the disk in any way, it simply
659 reports on any inconsistencies found. To actually "fix" a
660 disk CHKDSK must be run with the F switch (Fix). This allows
661 you to perhaps take some alternate (to CHKDSK repairs) action
662 before letting CHKDSK loose on your disk.
663
664 CHKDSK 2.00 will report on non-contiguous allocation units
665 (extents) for specified files. This is handy for gaging how
666 "fragmented" a disk volume has become. This is done by simply
667 giving a filespec:
668
669 CHKDSK B:*.*
670
671 This would report extents for all files in the current
672 directory for drive B after doing a normal consistency check
673 on drive B. Files which have many extents can be copied and
674 renamed to restore them to a contiguous state, thus improving
675 I/O performance to the files.
676
677 Previous versions of CHKDSK would simply free
678 allocation units which were marked as used, but were not
679 actually part of any file. CHKDSK 2.00 will recover these
680 "orphan" allocation units if specified. If orphan allocation
681 units are found, CHKDSK prompts for free or recover. Free
682 just frees the orphans as previous versions did, recover will
683 employ allocation chain analysis to create "orphan files" in
684 the root directory of the disk. These files will have the
685 form "%ORPHAN%.l$$" where l will take on some ASCII value
686 greater than '@'. These files may then be inspected to see if
687 valuable data was contained in them. If there is not enough
688 room to make all of the "orphan" files, CHKDSK leaves the
689 unrecovered chains in the FAT so that CHKDSK can be run again
690 (once some entries in the ROOT have been deleted). NOTE:
691 Making ORPHAN files is a SLOW process.
692
693 Verbose mode. CHKDSK 2.00 may be run with the V switch
694 which causes a trace of the files and directories being
695 processed to be printed as CHKDSK runs.
696
697 \f
698 FILTERS FOR MS-DOS 2.0
699
700 A filter is a utility that reads from standard input,
701 modifies the information in some way, then writes the result
702 to standard output. In this way the data is said to have been
703 "filtered" by the program. Since different filters can be
704 piped together in many different ways a few filters can take
705 the place of a large number of specific purpose programs. The
706 following describes the filters that are provided with MS-DOS
707 2.0:
708
709 CIPHER <key word>
710
711 Cipher reads a program from standard input, encrypts it
712 using the key word provided by the user, then writes the
713 result to standard output. To decrypt the file simply run
714 CIPHER again using the same keyword. For example:
715
716 A>CIPHER MYSTERY <NSA.CIA >SECRET.FIL
717
718 This command line will read file NSA.CIA, encrypt it using
719 the key word "MYSTERY", then write the result to file
720 SECRET.FIL To view the original file the following command
721 line could be used:
722
723 A>CIPHER MYSTERY <SECRET.FIL
724
725 This will read file SECRET.FIL, decrypt the file using the
726 key word "MYSTERY", then write the result to standard output,
727 which in this case is the console.
728
729 FGREP
730
731 This filter takes as arguments a string and optionally a
732 series of file names. It will send to standard output all
733 lines from the files specified in the command line that
734 contain the string.
735
736 If no files are specified FGREP will take the input from
737 standard in. The format for the command line invocation of
738 FGREP is:
739
740 FGREP [<option>] <string> <filename>*
741
742 The options available are:
743
744 /v Will cause FGREP to output all lines NOT
745 containing the specified string.
746
747 /c Will cause FGREP to only print the count of
748 lines matched in each of the files.
749
750 /n Each line matched is preceded by its relative
751 line number in the file.
752
753 The string argument should be enclosed in double quotes.
754 Two double quotes in succession are taken as a single double
755 quote. So,
756
757 A>FGREP "Fool""s Paradise" book1.txt book2.txt bible
758
759 will output all lines from the book1.txt, book2.txt and bible
760 (in that order that contain the string: Fool"s Paradise .
761 And,
762
763 A>dir b: | fgrep /v "DAT"
764
765 will output all names of the files in disk b: which do not
766 contain the string DAT .
767
768 MORE
769
770 The filter MORE reads from standard input, sends one
771 screen full of information to standard output and then pauses
772 with message:
773
774 -- More --
775
776 Pressing the RETURN key will cause another screen full of
777 information to be written to standard output. This process
778 continues until all the input data is read.
779
780 SORT [/R] [/+n]
781
782 Sort reads from standard input, sorts the data, the writes
783 the information to standard output. The sort is done using
784 the ASCII collating sequence. There are switches which allow
785 the user to select various options:
786
787 R - Reverse the sort, that is make "Z" come before "A"
788
789 +n - Sort starting with column "n" where n is some integer.
790 The default is start the comparisons with column 1,
791 this switch allows the user to start in any column.
792
793 example:
794
795 A>SORT /R <UNSORT.TXT >SORT.TXT
796
797 This command line will read the file UNSORT.TXT, do a reverse
798 sort, then write the output to file SORT.TXT
799
800 A>DIR | SORT /+14
801
802 This command line will cause the output of the directory
803 command to be piped to the sort filter, the sort filter will
804 sort starting with column 14 (This is the column the file size
805 starts), then send the output to the console. Thus a
806 directory sorted by file size will be the result. To get real
807 fancy:
808
809 A>DIR | SORT /+14 | MORE
810
811 will do the same thing except that MORE will give you a chance
812 to read the directory before it scrolls off the screen.
813