DDDDSSSSHHHH 1 TTTThhhheeee DDDDOOOOSSSS SSSShhhheeeellllllll ((((ddddsssshhhh)))) D. B. Preston W. M. Brelsford July 11, 1985 1. IIIInnnnttttrrrroooodddduuuuccccttttiiiioooonnnn The DOS shell is a set of UNIX1 commands that emulate the syntax and function of MS-DOS2 commands. The emulation does not extend to reproducing the output of the DOS commands exactly, but rather provides the same functionality to the extent possible or appropriate. In addition to the DOS commands, all UNIX System V commands are also available to dsh, to the extent that they are not in direct conflict with DOS commands. In some cases (e.g., the find command), the DOS and UNIX syntax is sufficiently different that both are available simultaneously. The DOS-like environment is entered by typing ``dsh'' at the UNIX prompt, or executing dsh at the bottom of the profile. In addition to the complete set of DOS commands, dsh provides a command (i.e., ``dtrace on'' and ``dtrace off'') to print the System V command corresponding to the given DOS command before execution. This feature is a useful teaching aid for those familiar with DOS who would like to learn UNIX painlessly. The DOS shell is efficient, however, and could be used by people who must use both DOS and UNIX, and would like a standard command-level interface. 2. DDDDOOOOSSSS ccccoooommmmmmmmaaaannnnddddssss A complete listing of DOS commands follows. This manual is not intended to document the commands, but rather to indicate which functions and options are supported by dsh. As such, it is more of an ``exception report,'' and must by read with the DOS User's Guide. The major differences are discussed below. __________ 1. UNIX is a trademark of AT&T. 2. MS-DOS is a trademark of Microsoft Corp. 2 DDDDSSSSHHHH Except for BREAK, FOR, IF, SET and TIME, all DOS commands are recognized in lower as well as upper case. Similarly, all DOS flags (e.g., /W in DIR) are recognized in both upper and lower case. Each flag must be preceded by a blank, however. Unlike DOS, DIR/W will not be recognized by dsh, for example. Since dsh is operating in the UNIX environment, ssssllllaaaasssshhhheeeessss ((((rrrraaaatttthhhheeeerrrr tttthhhhaaaannnn bbbbaaaacccckkkk----ssssllllaaaasssshhhheeeessss)))) ddddeeeennnnooootttteeee ddddiiiirrrreeeeccccttttoooorrrriiiieeeessss.... DOS variables are denoted by percent signs, fore and aft (e.g., %file%). In UNIX, variables are usually denoted by a leading dollar sign (e.g., $file), but may have braces added (e.g., ${file}), if necessary to separate the variable name from its context. UNIX variables cannot contain blanks, however. Input and output redirection and pipes are syntactically equivalent in DOS and UNIX. The ``aliasing'' features of the Korn shell (ksh) are used heavily by dsh, so ksh must be available to run dsh. All the features of ksh, to the extent they are not in conflict and thus disabled by dsh, are available. 2.1 AAAASSSSSSSSIIIIGGGGNNNN ((((aaaassssssssiiiiggggnnnn)))) The DOS function of assign is to direct requests between disk drives. The UNIX analog is mounting a new file system, and assigning it a name. Thus ASSIGN is aliased with ``mount'', and a typical use would be ``assign /dev/floppy=/mnt''. As with DOS, both the physical device (/dev/floppy in the example), and the directory (/mnt) which is to become the root of the new file system, must exist beforehand. The UNIX command ``umount'' is then needed, and is equivalent to ASSIGN without arguments. 2.2 BBBBAAAACCCCKKKKUUUUPPPP ((((bbbbaaaacccckkkkuuuupppp)))) BACKUP backs up files or directories, using cpio. In dsh, it operates to a directory, rather than a disk drive as in DOS. The /P (pack) flag is ignored, and the /A (add) flag will overwrite an existing file with the same name. All other flags operate as in DOS. 2.3 BBBBRRRREEEEAAAAKKKK BREAK turns on and off interpretation of CTRL-C as an interrupt, exactly as in DOS. The lower case version is reserved for the UNIX function (breaking out of loops). DDDDSSSSHHHH 3 2.4 CCCCDDDD ((((ccccdddd)))) This a synonym of CHDIR (below). 2.5 CCCCHHHHDDDDIIIIRRRR ((((cccchhhhddddiiiirrrr)))) Changing the active directory is done by the UNIX cd command, and listing the current directory by the echo command. ``CHDIR /xyz'' will change to directory xyz under the user's HOME directory, or root (in order of search); ``CHDIR xyz'' searches the current directory first, then the home directory. Note: ``CHDIR ..'' from the /bin directory will get to the real root (i.e., /) if necessary. UNIX file systems are the closest analog of DOS disk drives. However, CHDIR is able to cross file systems, so there is no need for a UNIX analog of the DOS command ``C:'' to change to the C disk. 2.6 CCCCHHHHKKKKDDDDSSSSKKKK ((((cccchhhhkkkkddddsssskkkk)))) Disk consistency checking and repair is done by fsck. All options are supported. 2.7 CCCCLLLLSSSS ((((ccccllllssss)))) Screen clearing is terminal dependent, so the UNIX TERMINFO variable must be defined. This command requires System V, Release 2. 2.8 CCCCOOOOMMMMMMMMAAAANNNNDDDD ((((ccccoooommmmmmmmaaaannnndddd)))) Calling another copy of the command processor is the equivalent of dsh. 2.9 CCCCOOOOMMMMPPPP ((((ccccoooommmmpppp)))) Comparing files, or a group of files is done by cmp, with some help from ls and xargs. The result is completely equivalent to the DOS version. 2.10 CCCCOOOOPPPPYYYY ((((ccccooooppppyyyy)))) The DOS COPY command is complex, with two primary syntaxes, one to copy and one to append. Both are supported by dsh. The /V (verify), /B (binary), and /A (ASCII) flags are ignored, since they are irrelevant for UNIX. 4 DDDDSSSSHHHH 2.11 CCCCTTTTTTTTYYYY ((((ccccttttttttyyyy)))) CTTY works as documented in DOS. See the section on reserved file names, however. 2.12 DDDDAAAATTTTEEEE ((((ddddaaaatttteeee)))) DATE is special case of the UNIX date. Only the superuser has permission to change the system date, so an error message is displayed if a date change is attempted by others. The proposed new date is printed, however. 2.13 DDDDEEEELLLL ((((ddddeeeellll)))) This is almost the same as the UNIX rm command. The difference is a ``safety net'' to catch deletion of multiple files. 2.14 DDDDIIIIRRRR ((((ddddiiiirrrr)))) Directory listings are done by ls with various flags. All DOS flags are supported, but System V, Release 2 is required. 2.15 DDDDIIIISSSSKKKKCCCCOOOOMMMMPPPP ((((ddddiiiisssskkkkccccoooommmmpppp)))) Comparing whole disks (file structures) in UNIX is usually meaningless, so DISKCOMP compares directories. The /L and /8 flags are meaningless to UNIX, and are ignored. 2.16 DDDDIIIISSSSKKKKCCCCOOOOPPPPYYYY ((((ddddiiiisssskkkkccccooooppppyyyy)))) Copying whole disks (file structures) in UNIX is usually meaningless, so DISKCOPY copies directories. The target directory must exist beforehand. 2.17 EEEECCCCHHHHOOOO ((((eeeecccchhhhoooo)))) ECHO is identical to the UNIX echo, except when called in a .bat file with the single argument ``on'' or ``off'', which toggles the x option of set. 2.18 EEEEDDDDLLLLIIIINNNN ((((eeeeddddlllliiiinnnn)))) Technically, EDLIN is not a DOS command, but an application program. Note that it is documented in an appendix of the DOS manual. The EDLIN line editor is the functional equivalent of ed, but the similarity does not stop there. See Table 1 for a command-by-command comparison. The command line editing function keys do not work within EDLIN. DDDDSSSSHHHH 5 TTTTAAAABBBBLLLLEEEE 1111.... Editor Commands ________________________________________________________________ _|_F__FFFu__uuun__nnnc__ccct__ttti__iiio__ooon__nnn______________E__EEED__DDDL__LLLI__IIIN__NNN____________________________________________e__eeed__ddd______________________________________| |Append Lines [lines]A r filename | | from disk | _|_______________________________________________________________| _|A_p_p_e_n_d__L_i_n_e_s_______________________________[_l_i_n_e_]_a_______________| |Copy Lines [line][,line],line,[cnt]C [line][,line]t[line] | _|_______________________________________________________________| _|D_e_l_e_t_e__L_i_n_e_s____[_l_i_n_e_]_[_,_l_i_n_e_]_D______________[_l_i_n_e_]_[_,_l_i_n_e_]_d________| |Edit Line [line] [line] | _|_______________________________________________________________| |Exit Editor E w | _|___(_s_a_v_e_)__________________________________q_____________________| |Insert Lines [line]I [line]i | _|_______________________________________________________________| _|E_n_d__I_n_s_e_r_t_i_o_n___C_T_R_L_-_Z______________________.__(_c_o_l_u_m_n__1_)__________| |Help Mode H | _|_______________________________________________________________| _|P_r_i_n_t__L_i_n_e_s_____[_l_i_n_e_]_[_,_l_i_n_e_]_L______________[_l_i_n_e_]_[_,_l_i_n_e_]_p________| |Move Lines [line][,line],lineM [line][,line]m[line] | _|_______________________________________________________________| _|P_a_g_e____________[_l_i_n_e_]_[_,_l_i_n_e_]_P______________[_l_i_n_e_,_l_i_n_e_+_2_2_]_p_______| |Quit Editor Q Q | | (no save) | _|_______________________________________________________________| |Substitute [line][,line][?]Rstring1CTRL-Zstring2 | _|___T_e_x_t______________________[_l_i_n_e_]_[_,_l_i_n_e_]_s_/_s_t_r_i_n_g_1_/_s_t_r_i_n_g_2_[_/_g_]__| |Search Text [line][,line]S[string] /string | _|_______________________________________________________________| _|T_r_a_n_s_f_e_r__L_i_n_e_s__[_l_i_n_e_]_T_f_i_l_e_n_a_m_e_____________[_l_i_n_e_]_r__f_i_l_e_n_a_m_e______| |Write Lines [n]W [line][,line]w | _|_______________________________________________________________| 2.19 EEEERRRRAAAASSSSEEEE ((((eeeerrrraaaasssseeee)))) This is a synonym for DEL. 2.20 EEEEXXXXEEEE2222BBBBIIIINNNN ((((eeeexxxxeeee2222bbbbiiiinnnn)))) The UNIX analog is strip. 2.21 EEEEXXXXIIIITTTT ((((eeeexxxxiiiitttt)))) The UNIX exit is identical in function. 6 DDDDSSSSHHHH 2.22 FFFFCCCC ((((ffffcccc)))) File comparisons are done by diff, after preprocessing by tr in some cases. All DOS flags are supported. 2.23 FFFFDDDDIIIISSSSKKKK ((((ffffddddiiiisssskkkk)))) FDISK provides an environment, and as such has no command syntax. The equivalent UNIX function is available (to superusers) in mkfs. 2.24 FFFFIIIINNNNDDDD ((((ffffiiiinnnndddd)))) FIND is a special case of the UNIX grep. 2.25 FFFFOOOORRRR The DOS FOR command (note that ``for'' is still the UNIX command, since it is a keyword that cannot be over-written or aliased) works as documented, except that the parentheses must be square (i.e., [...]), or protected with backslashes (i.e., \(...\)). The ``variable'' in the FOR command is really a dummy variable, and should be denoted, as in DOS, by a percent sign. For example, FOR %i in [ a b c ] do echo %i $xyz 2.26 FFFFOOOORRRRMMMMAAAATTTT ((((ffffoooorrrrmmmmaaaatttt)))) As with DOS, FORMAT formats floppy disks. 2.27 GGGGOOOOTTTTOOOO ((((ggggoooottttoooo)))) GOTO is a DOS batch command that has no direct UNIX analog. The branching of GOTO is done using the UNIX case command. A batch compiler has been provided, that, when invoked from within dsh, will translate a DOS batch file (i.e., .bat file) into the corresponding UNIX shell script. See the section on batch files below. 2.28 GGGGRRRRAAAAPPPPHHHHIIIICCCCSSSS ((((ggggrrrraaaapppphhhhiiiiccccssss)))) GRAPHICS dumps the screen to a printer, exactly as in DOS. The mc0 entry from the TERMINFO database is used, since this is terminal dependent. 2.29 IIIIFFFF Except for the lack of a lower case version, IF works exactly the same as the DOS version. DDDDSSSSHHHH 7 2.30 MMMMDDDD ((((mmmmdddd)))) MD is a synonym for MKDIR (below). 2.31 MMMMKKKKDDDDIIIIRRRR ((((mmmmkkkkddddiiiirrrr)))) MKDIR is identical to the UNIX mkdir. 2.32 MMMMOOOODDDDEEEE ((((mmmmooooddddeeee)))) The functions of MODE are provided by stty, among other commands. Because the UNIX environment is multiuser, these functions are usually defined once and for all by the superuser, with careful reference to the appropriate manual. The characteristics of the available devices are then made known to all users, who choose, rather than define, their devices. Under dsh, MODE does nothing. 2.33 MMMMOOOORRRREEEE ((((mmmmoooorrrreeee)))) Identical to the UNIX pg with a specific set of options. 2.34 PPPPAAAATTTTHHHH ((((ppppaaaatttthhhh)))) PATH is a function to set the UNIX PATH variable ($PATH), or print it if there are no arguments. As in DOS, the current directory is always searched first, no matter what PATH is defined to be. If semicolons are used to separate segments of the PATH, they must be entered with a backslash (i.e., \;), since the semicolon is the UNIX command terminator that permits multiple commands per line. Colons may be used in place of semicolons in the PATH command line, if desired. 2.35 PPPPAAAAUUUUSSSSEEEE ((((ppppaaaauuuusssseeee)))) PAUSE stops, issues a prompt, and waits for input (which it ignores), exactly as in DOS. 2.36 PPPPRRRRIIIINNNNTTTT ((((pppprrrriiiinnnntttt)))) PRINT is the DOS printer spooler, the analog of lp. UNIX has true concurrency, so the /T (terminate), /C (cancel), and /P (resume printing) flags are ignored. PRINT returns a message containing a job number (called a ``request id''). Type ``cancel'' followed by the job number to halt the printing. Since there are typically multiple printers or multiple printer options available on a given UNIX installation, a provision has been made for customizing the PRINT command. The DOSPRINT variable is defined at installation. Users may re-define this variable, either in the UNIX profile, 8 DDDDSSSSHHHH autoexec, or from the keyboard, to be the UNIX command sequence needed to spool print jobs to the desired local printer. Typically this command would be something like SET DOSPRINT = lp -d x1 in the autoexec file to send print output to printer x1. See the section on Initialization below. 2.37 PPPPRRRROOOOMMMMPPPPTTTT ((((pppprrrroooommmmpppptttt)))) PROMPT defines the prompt string. By default, the DOS prompt is the drive (i.e., file structure) name. In UNIX, the file structures are unified from the user's point of view, so a prompt showing the top directory only is not informative. The default prompt string for dsh, therefore, is the home directory name if the user is in the home directory, the subdirectory path if below the home directory, and the complete path otherwise. When in the home directory, or outside it, a complete path name (``fully qualified'' in the jargon) starting with a ``/'' is displayed. When below the home directory, only the part of the path below the home directory (no leading ``/'') is displayed. Many UNIX users prefer the shorter prompt that corresponds to ``PROMPT $p$g'', showing only the current directory name. The prompt is under the user's complete control, and all the DOS ``$'' mnemonics have been implemented. In addition, the DOS reverse video toggles ($e[7m and $e]m) are intercepted and translated into the appropriate sequences. Unlike DOS, however, other variables can be inserted in the prompt string by merely adding them to the list. 2.38 RRRRDDDD ((((rrrrdddd)))) RD is a synonym for RMDIR (below). 2.39 RRRREEEECCCCOOOOVVVVEEEERRRR ((((rrrreeeeccccoooovvvveeeerrrr)))) There is no direct UNIX analog. Recovery of the usable pieces of files is done by fsck automatically (see also CHKDSK). 2.40 RRRREEEEMMMM ((((rrrreeeemmmm)))) Remark is provided by ``#'' in UNIX. DDDDSSSSHHHH 9 2.41 RRRREEEENNNN ((((rrrreeeennnn)))) Renaming is done by mv with some preliminary processing to honor wild-cards in the DOS style. 2.42 RRRREEEENNNNAAAAMMMMEEEE ((((rrrreeeennnnaaaammmmeeee)))) A synonym for REN (above). 2.43 RRRREEEESSSSTTTTOOOORRRREEEE ((((rrrreeeessssttttoooorrrreeee)))) The inverse of BACKUP, RESTORE also uses cpio. All flags work as defined. 2.44 RRRRMMMMDDDDIIIIRRRR The RMDIR command is identical to the UNIX command of the same name. 2.45 SSSSEEEETTTT The SET command defines and exports shell variables, exactly the same in DOS and UNIX. 2.46 SSSSHHHHIIIIFFFFTTTT ((((sssshhhhiiiifffftttt)))) Identical in both DOS and UNIX. 2.47 SSSSOOOORRRRTTTT ((((ssssoooorrrrtttt)))) The DOS SORT command is a special case of the UNIX sort. 2.48 SSSSYYYYSSSS ((((ssssyyyyssss)))) SYS copies the hidden system files in DOS. No UNIX analog is needed. 2.49 TTTTIIIIMMMMEEEE TIME is a special case of the UNIX date command. Only the superuser has permission to change the system time, so an error message is displayed if a time change is attempted by others. The proposed new time is printed, however. 2.50 TTTTRRRREEEEEEEE ((((ttttrrrreeeeeeee)))) TREE is a special case of ls. All options are functional. 10 DDDDSSSSHHHH 2.51 TTTTYYYYPPPPEEEE ((((ttttyyyyppppeeee)))) TYPE is equivalent to the UNIX cat. 2.52 VVVVEEEERRRR ((((vvvveeeerrrr)))) VER displays the UNIX operating system Version number. 2.53 VVVVEEEERRRRIIIIFFFFYYYY ((((vvvveeeerrrriiiiffffyyyy)))) No UNIX analog is needed. UNIX verifies copies automatically, returning ``Bad copy ...'' when one is discovered. 2.54 VVVVOOOOLLLL ((((vvvvoooollll)))) The UNIX command ``df'' reports the name and total free space for each file system. 3. BBBBaaaattttcccchhhh PPPPrrrroooocccceeeessssssssiiiinnnngggg CCCCoooommmmmmmmaaaannnnddddssss All the DOS batch processing commands are available in dsh. Batch files (command_name.bat or command_name.BAT) must be converted to executable shell procedures. The command batc command_name will translate the DOS batch file command_name.bat or command_name.BAT into the corresponding UNIX shell script, which will be stored in command_name (i.e., the ``.bat'' is stripped) in the same directory. The command command_name arg1 arg2 .. will then work in exactly the same way under dsh as under DOS. The command batcg command_name arg1 arg2 .. will convert the batch file and then execute it. Alternatively, the command make command_name uses the UNIX make facility to translate the DOS batch file command_name.bat or command_name.BAT into the corresponding UNIX shell script, if the batch file has been updated more recently than the shell script. DDDDSSSSHHHH 11 The processing performed on DOS batch files includes: 1. conversion of GOTO statements into a UNIX case construct; 2. translation of break, for, if, set and time to upper case; 3. conversion of parentheses in FOR statements to square brackets; 4. conversion of DOS variables (%name%) and parameters (%0, %1, .., %9) to their UNIX counterparts (and of %% to %); 5. conversion of backslashes to slashes. 4. MMMMiiiisssscccceeeellllllllaaaannnneeeeoooouuuussss 4.1 RRRReeeesssseeeerrrrvvvveeeedddd ffffiiiilllleeee nnnnaaaammmmeeeessss aaaannnndddd eeeexxxxtttteeeennnnssssiiiioooonnnnssss DOS reserves six filenames (AUX, CON, PRN, COM1, COM2 and NUL) for the auxiliary device, console, printer, communications ports 1 and 2, and trash. These cannot be hardwired in UNIX, since they could be different for each user. Therefore, they have been converted to variables ($AUX, $CON, $COM1, $COM2, $PRN, and $NUL) and initialized by dsh (to /dev/tty for $CON and /dev/null for the others). $AUX $COM1, $COM2 and $PRN can be redefined by the user. For example, SET PRN = /dev/lp1 is a typical definition if a printer is attached. A typical usage would then be TYPE file1 >$PRN UNIX makes use of file extensions (e.g., .c for C program source, .o for object code, etc.) of arbitrary length, not just the three characters of DOS. The .bat and .BAT extensions are recognized by the UNIX make command, when invoked from the dsh environment, as DOS code to be compiled to a dsh command file. Once compiled, typing the filename and any arguments will result in execution, exactly analogous to DOS. The .exe and .com extensions are meaningless to UNIX. 12 DDDDSSSSHHHH 4.2 IIIInnnniiiittttiiiiaaaalllliiiizzzzaaaattttiiiioooonnnn If dsh finds an ``autoexec'' file in the user's home directory, it will execute it when it first starts. This is analogous to DOS execution of an ``autoexec.bat'' file, but dsh requires the compilation to ``autoexec''. In addition, dsh will define CTRL-C to be the interrupt and line-delete sequence when it initializes. 4.3 FFFFuuuunnnnccccttttiiiioooonnnn KKKKeeeeyyyyssss DOS initializes the first five function keys (F1-F5) to permit editing of the previous command. A similar capability exists in dsh, but the keys must be loaded by the user. On most terminals, this can be done once, and then remembered or down-loaded as needed. The key definitions in Table 2 are recommended, since the first five keys closely match the DOS definitions. TTTTAAAABBBBLLLLEEEE 2222.... Function Key Definitions ____________________________________________ _|K_KKKe_eeey_yyy_L_LLLa_aaab_bbbe_eeel_lll____D_DDDe_eeef_fffi_iiin_nnni_iiit_ttti_iiio_ooon_nnn_F_FFFu_uuun_nnnc_ccct_ttti_iiio_ooon_nnn___________| |F1 NEXT ^F Move cursor to | | CHAR next position | _|___________________________________________| |F2 FIND ^] Find next instance | | CHAR of a given | _|________________________c_h_a_r_a_c_t_e_r___________| |F3 TO END ^E Move cursor to end | | OF LINE of line | _|___________________________________________| |F4 DELETE ^D Delete character | _|____C_H_A_R_________________a_t__c_u_r_s_o_r___________| |F5 REFRESH ^A_e_s_c-p^L Refresh the | | command line | | display | _|___________________________________________| |F6 EDIT ^P^A Edit previous | | PREV command | _|____C_M_D_____________________________________| |F7 DELETE ^K Delete all | | TO EOL characters to the | | end of the line | _|___________________________________________| |F8 PREV ^B Move cursor to | _||____C_H_A_R_________________p_r_e_v_i_o_u_s__c_h_a_r_a_c_t_e_r__|| In the table, ^X represents CTRL and key X (simultaneously), and _e_s_c-X represents escape followed by key X. DDDDSSSSHHHH 13 With these function key definitions, any previously issued command may be recalled (by pushing the F6 button multiple times) and edited. Those familiar with UNIX will recognize the function key definitions as emacs editor commands, and indeed, most of the emacs editor is available to process the command history. The emacs commands can be given directly from the keyboard, if desired. One emacs command that is useful, and can be used with the function keys, is _e_s_c- number. When an _e_s_c-number is followed by a function key, the effect of the function key is multiplied by the number. For example, _e_s_c-10 followed by F6 retrieves the tenth previous command. The command editing is not completely identical to DOS, but is similar, easy to use, and more powerful. 4.4 IIIInnnnssssttttaaaallllllllaaaattttiiiioooonnnn The dsh commands should be saved in a file not customarily searched by vanilla UNIX users, since some dsh commands overwrite UNIX commands with the same name. The dsh shell script itself should be copied to a directory that is searched, so that it will become available for execution. The installation procedure has been mechanized to the greatest extent possible. After moving all source files to the directory where they are to be kept, and changing to that directory, type dsh_install dirname printer commands where dirname is the name of the directory to be searched for dsh (typically NNNNOOOOTTTT the directory containing the source), and the rest of the command line is the UNIX command to be used as the default printer command. Be sure you have write permission for dirname. The printer commands are optional, and will default to ``lp''. For example, dsh_install /usr/lbin lp -d x10 will install the dsh command in /usr/lbin, and spool user's print requests to destination x10 via the lp command.