DOS Tutorial 1. To get a DOS prompt, click Start, then Run, then type command.com 2. The screen should look something like this: Microsoft(R) Windows 95 DOS (C)Copyright Microsoft Corp 1990-1996 C:\WINDOWS\DESKTOP> 3. The > is your command prompt; it tells you that DOS is ready to receive input. To get a directory listing, type dir C:\WINDOWS\DESKTOP> dir Volume in drive C has no label. Volume Serial Number is B0C1-3D14 Directory of C:\WINDOWS\DESKTOP 07/18/01 12:00p . 07/18/01 12:00p .. 07/19/01 11:32p Data 04/23/01 01:47a data.txt 1 File(s) 10 bytes 9,098,011,136 bytes free Note that the directory listing always contains the special directories . (current directory) and .. (parent directory). Directories are labeled . 4. To change to a subdirectory (say "Data") you can use the cd command. (For change directory): C:\WINDOWS\DESKTOP>cd data C:\WINDOWS\DESKTOP\Data> 5. Say you are now in the directory C:\WINDOWS\DESKTOP\Data\, indicated by the command prompt C:\WINDOWS\DESKTOP\Data> To change to a directory one level up from the current one, you can type cd .. C:\WINDOWS\DESKTOP\Data> cd .. C:\WINDOWS\DESKTOP> To change to the root directory, you can type cd\ (that's a backslash, not a forward slash!) C:\WINDOWS\DESKTOP> cd\ C:\> To change to a different folder (say Documents) you can now type C:\> cd documents C:\DOCUMENTS> or, alternately, C:\> cd docume~1 C:\DOCUME~1> The second form is a consequence of the old 8-character filename limitation from the original DOS. It may be the only one that works on certain machines. Just hit DIR and look for the first six characters of the directory you want, followed by ~1 or another number. You can also change directories more quickly by typing (for example) C:\DOCUME~1> cd\windows\desktop C:\WINDOWS\DESKTOP> Now you should be able to move freely between directories at a command prompt. 6. To save yourself the trouble, just bring up Windows Explorer by holding down the Windows key (next to Alt) and hitting E. Navigate graphically to the proper directory, then run command as in step 1. If DOS is configured properly, it will probably start in the directory you've navigated to automatically. If not, cry for a bit and then change directories manually as above. 7. Make it easy on yourself, and keep the program you need to run right where it is, but put any data files you're using in the directory with the program. This spares you the hassle of telling the program where the file is, and allows you to use just its name instead of its full path. (The path to a file is just how to get there from the root directory---where you go when you type cd\). So the full path to a file data.txt on the desktop is c:\windows\desktop\data.txt Note that you can move files using Windows Explorer. 8. Now that you are in the directory where the program is, and the data files are in the same directory, you're ready to run the program. Type dir to get a listing if you've forgotten the name of the program. It should be somewhere in the list. If it isn't, you're in the wrong directory. Just type the name of the program, and it should give you a brief reminder on how to use it. If not, try the program name followed by -help /help -? or /? to access a help message: C:\>DOSKEY /? 9. Command line switches are how you provide arguments to a program. For example, try typing C:\>dir /w The /w is a command line switch that tells the dir program to output in wide format. Type dir /? for help on the other arguments. Neat, eh? 10.In UNIX, command line switches are generally given with dashes (-) instead of slashes (/). Certain Mie fitting routines also follow this convention. So for them, you might type C:\Documents\Mie Programs> fitmie -? 11.Some of these programs also require arguments other than switches. Another example of such a program is the DOS utility ren, which renames a file. The syntax is ren oldfilename newfilename. Try it out! C:\Documents> dir Volume in drive C has no label. Volume Serial Number is B0C1-3D14 Directory of C:\Documents 07/18/01 12:00p . 07/18/01 12:00p .. 04/23/01 01:47a data.txt 1 File(s) 10 bytes 9,098,011,136 bytes free C:\Documents> ren data.txt suckydata.txt C:\Documents> dir Volume in drive C has no label. Volume Serial Number is B0C1-3D14 Directory of C:\Documents 07/18/01 12:00p . 07/18/01 12:00p .. 04/23/01 01:47a suckydata.txt 1 File(s) 10 bytes 9,098,011,136 bytes free The same space-delimited format for passing arguments is used in the Mie fitting routines. So you might type something like C:\Documents> fitmie data.txt theory.txt -pol 2 to pass the files data.txt and theory.txt to the fitmie program with the option -pol 2. In this case, the -pol switch has its own argument, given after the switch, separated by a space. 12.One more thing about help messages. The conventions on this are somewhat hazy, so watch out for variations. But if you see the usage message C:\Documents> fitmie Usage: fitmie datafile theoryfile [-pol {1,2,3}] it means that you have to call fitmie with two arguments (the first two) that give the names of a data file and a theory file. The -pol switch (or any switch in [] brackets) is optional, and the {} braces mean that you must give one of the values in that list as an argument. So you could type C:\Documents> fitmie data.txt theory.txt C:\Documents> fitmie data.txt theory.txt -pol 2 but not C:\Documents> fitmie data.txt C:\Documents> fitmie data.txt theory.txt moretheory.txt C:\Documents> fitmie data.txt theory.txt -pol C:\Documents> fitmie data.txt theory.txt -pol 4 Each of these options should give you a separate, informative error message explaining what you're doing wrong. Provided you're not TOO creative, that is. 13.Another useful DOS feature is piping and redirection. This basically allows you to feed the output of one program into the input of another, or to redirect the output of a program to a file. An example of a pipe is as follows: C:\Documents> type data.txt | more In this command, data.txt is an argument to the type program, which just outputs the contents of a file to the screen. The vertical bar is called a pipe, and instructs the operating system to feed all output into the input of the next program. In this case, that program is "more", which just prints its output to the screen one full screen at a time, waiting for the user to press a key before advancing the screen. Thus, the net effect of the above command is to type the contents of data.txt to the screen, one page at a time. The redirect is actually an even simpler concept. Instead of passing the output to another program, a redirect operator just records the output in a specified file. So, for example, C:\Documents> type data.txt >> output.txt writes the data.txt file to standard output (usually the screen), but the redirect points standard output to the file output.txt instead. So the net effect is to get the contents of data.txt and write it to the file output.txt---essentially a copy command for text files! The operating system provides a more convenient method in the form of the copy command, of course, but our purpose is to illustrate the redirect. Redirection is used with the mietable program (for example) to redirect the program's output to an appropriate file. So instead of typing C:\Documents> mietable 1 10 1 1.2 which outputs to the screen, you might want to type C:\Documents> mietable 1 10 1 1.2 >> tables.txt to write the results to tables.txt. Use redirection whenever you want to record what gets sent to the screen in a file instead. Note that this is not needed for a program like snell, which takes two parameters that specify an input file and an output file. If you do redirect snell's output, you'll either get nothing, or just the progress indicator. 14.Last, when you're done running programs and reading error messages, you can type exit to close the command line: C:\Documents> exit and the window should close. SPECIAL BONUS MATERIAL!!! 1. You can adjust the properties of your DOS window by clicking the MSDOS icon in the top left corner of the window and selecting properties from the drop-down menu. It never hurts to increase the number of rows in the window from 25 to something more useful like 50. Do whatever fits on the screen. Don't change memory settings unless things aren't working properly for memory reasons. 2. DOSKEY is a very useful program if you're going to spend an extended period of time at the command line. It's run automatically at startup on many computers, so it may be installed right now! Just in case, go to a command line and type C:\WINDOWS\DESKTOP> DOSKEY /INSERT to start the program. Then type a command. Let's just try dir C:\WINDOWS\DESKTOP> dir Now, to repeat this command (and possibly edit it), just hit the up arrow key. The entire command appears! Not so useful for three-character commands, but it gets much more useful if you have hundred-character commands. Furthermore, you can push the up arrow multiple times to recall more commands all the way back to when you first ran DOSKEY. Type DOSKEY /? for a full list of options for the program. Macros are a very useful feature that you can figure out how to use on your own.