• No results found

Using a Temporary Directory

In document Using Ms-dos 6.22 (Page 155-158)

Many programs and some DOS operations use a directory as a temporary location to store scratchpad files. A scratchpad file is a file that is created as a buffer to store information tem-porarily before a permanent file is created. A good example of a program that uses tempo-rary storage space is Windows. Windows creates .TMPfiles in the temporary directory to hold swapping information. Also, the Windows Print Manager uses the temporary directory to create files to hold print jobs. Other programs use temporary space as a place to store sorting information, backup copies of files being processed, and so on.

Traditionally, DOS users have created a directory called TEMPthat branches off the root directory of C:. In fact, if this directory doesn’t exist when you install DOS 6.22 using the Setup program, it is created for you automatically.

The SETcommand, which creates DOS environment variables, normally is used in

AUTOEXEC.BATto create a variable called TEMP, as shown in this example:

SET TEMP=C:\TEMP

Redirecting Your Output

LikeDIRandTYPE,TREEis one of those DOS commands that can produce many pages of output. DOS offers two features to enable you to capture screen output in a more usable form.

You can use the MOREcommand to capture screen output from other commands and present the screens one at a time, pausing for a keystroke as each screen is displayed. MOREis unusual because you enter it on the command line of another command using the pipe (|) symbol, which you can find on the same key as the backslash on most keyboards. Check out the following command example:

TREE /F | MORE

The preceding command captures the output of the TREEcommand and passes it to the MOREcommand. The MOREcommand breaks up the output into single screen portions. As each single screenful of the output is dis-played,MOREwaits for you to press a key before it displays the next screenful.

The problem with MOREis that you cannot go backward. When a screenful of output has been replaced with another, the first screenful is lost. To see it again, you must repeat the command that called MORE.

You also can use the DOS redirection feature to capture long output to a file or send it directly to a printer by using the output redirection symbol (>), as in the following two examples:

TREE /F >TREE.TXT

Troubleshooting 125

TREE /F >PRN

The first example directs the output to be saved in a file named TREE.TXT. You then can use an editor to view the output of the TREEcommand. If your editor has problems displaying graphic characters, use the /Aswitch to get readable output.

The second example directs the output of the TREEcommand to the printer. Make sure the printer is online and ready before you put the TREEcommand into action.

For more information on DOS’s redirection features, see Chapter 13.

When DOS or another program needs to create temporary files, it looks in the environment to see whether a TEMPvariable exists. This way, you can direct DOS to use a specific direc-tory. If you don’t have a TEMPdirectory, most software uses the currently logged directory to create scratchpad files. You should always make sure that the TEMPdirectory resides on a disk with plenty of free space. Lack of scratchpad space can make programs run much more slowly than normal or display an error message.

Most programs that create scratch files do a good job of cleaning up after themselves by deleting any files they might create when the files are no longer needed.

It is a good idea to check the TEMPdirectory every few days just to make sure that no scratchpad files have been orphaned by a power failure or untimely reboot. If you find files in the TEMPdirectory, you should delete them.

Be careful, however, not to delete files in the TEMPdirectory while you’re running Windows or when you’re shelled out to a DOS session from within a running applica-tion. Under these circumstances, the files still might be active and in use. Never delete files from the TEMPdirectory unless you are at a DOS prompt with no other programs running.

Troubleshooting

What happened to my filenames?

Modern operating systems, such as Windows 95/98/ME and Windows NT/2000, enable you to have filenames up to 256 characters. A common problem occurs when a user copies files with long filenames to a DOS machine that supports only the 8.3 filename format. DOS renames a long filename by truncating it and adding a tilde (~) and a numeric character.

If you copy the file CONVERTIBLE.EXEto a DOS machine, for example, you end up with a file called CONVER~1.EXE.

If you try to name a file with an illegal character or with too many characters in the exten-sion, you encounter other errors. The following example uses the COPYcommand to show what can happen:

COPY TEST.TXT 123456789.1234

126 Chapter 5 Understanding Files and Directories

Notice that both the filename and extension given for the destination filename contain an extra character: The filename has the extra character 9, and the extension has the extra char-acter 4. You might predict that DOS will issue a message warning that the filename and extension are too long. No such luck! DOS simply truncates the filename to eight characters and the extension to three characters to create a legal filename (12345678.123), and then it completes the COPYoperation.

Illegal characters in a filename can prevent DOS from carrying out a command. Here’s an example:

COPY 12345678.123 1[3.123

This command causes DOS to display the following message:

File creation error

Few experienced DOS users purposely use illegal characters in a filename, but typos easily can creep into your DOS commands and introduce illegal characters into filename parame-ters. Type commands carefully, remembering that DOS’s reaction to an illegal filename isn’t always predictable.

Understanding Disks and Disk

In document Using Ms-dos 6.22 (Page 155-158)