Last Name  First Name
Date Class Night

 

CIS 170 - Microcomputer Operating Systems

Prelab - Intro. to Redirection

Professor. Edward F. Bouling, IV

Unless you specify otherwise, DOS receives input from your keyboard and sends output to your screen. Sometimes it may be useful to redirect the input or output to a file or a printer. For example you may want to redirect a directory listing to file that you can retrieve and view later.

To redirect the input or output of a command , you can use one of the following redirection characters.

<, >, >>

Redirecting Output

The standard output redirection symbol is

When you executed the dir command, the commands output goes directly to the screen. To redirect the output to the printer instead use this format.

A:\CIS170>dir > prn

A:\CIS170>dir > lpt1

To redirect the output to a file instead of the screen, use this format. A:\CIS170>dir >dirfile.txt
 
 
WARNING When you redirect output to a file. DOS creates that file on disk. If the file already exists. It overwrites the existing file.

Appending output to the end of a file.

To add the output of a command to the end of a file without losing any of the information already stored in the file, use a double greater than sign ()

A:\CIS170>dir > dirfile.txt
 
Redirecting Input

Just as you can send the output of a command to a file or printer rather than the screen, you can force a command to take its input from a file rather than from the keyboard.

Redirecting input is a little trickier because all input is provided from a device or file other than the keyboard. It also means that you're telling DOS to ignore the keyboard. This means that with input redirection you must be sure whatever (device or file) is supplying input will be smart enough to eventually let the keyboard have control again.

To make DOS take its input from a file instead of the keyboard, use the less than character (<).

More < endless.txt

In this case the MORE filter receives input from the endless.txt text file on disk. This works because the text file tells DOS " Okay Iím done now," and control returns to the keyboard.

Whenever you use the input redirection character it must be used in such a way as to control can be returned back to the keyboard. If not, only the cntrl-alt-del keyboard combination will give you control of the system again.

Step One

Experiment with these redirection characters, try using them at least three times.

List the three examples you tried.
 
 
 
 
 
 

Step Two

Explain what happened. Did you run in to any problems? What were they?
 
 

Make a copy for yourself and give a copy to me