Ana səhifə

Ms-dos : MicroSoft Disk Operating System a practical demonstration


Yüklə 70.43 Kb.
tarix25.06.2016
ölçüsü70.43 Kb.

(MS-DOS) : MicroSoft - Disk Operating System
A practical demonstration.

Ref: 57.113:Laboratory & Tutorial Manual - "Computer Applications" - University of Waikato.


In this practical you will be looking at the MS-DOS operating system. By the end of the practical you should be able to use simple MS-DOS commands for producing a directory listing, creating a directory, moving from one directory to another, displaying a file on the screen, printing a file on paper, and copying, renaming, and deleting files. You should also be familiar with the concepts of a directory, directory tree, path, files and filenames.
Before doing this practical, you should have covered the theory notes on System software in the on-line v/2-eNcyclopedia

1 Why do you need an Operating System

The operating system is program that is responsible for seeing that the computer works correctly. It manages system resources such as the CPU, primary memory, secondary memory (disk drives) and systems input and output devices such as the keyboard, screen, and printer. It also provides the systems interface which is the part of the system that interacts with you, the person using the computer. This is the part of the operating system you actually see, and through which you can control the computer.


You might like to think of an operating system as an office secretary.

This secretary must

manage the filing

manage messages and requests from staff

provides client contact with your organisation.

manage room and resource bookings.


MS-DOS is the standard operating system for IBM PCs, ATs, and PC and AT clones. The acronym stands for MicroSoft Disk Operating System, and is frequently abbreviated to `DOS'. It uses a command line interface, which means commands are entered into the computer by typing the command names with the keyboard.
The advantages of such a system are simplicity and speed. The disadvantages are that you have to know the names and formats for the commands before you can use them, and when physically typing them in, you can be prone to errors.

2 What does it allow you to do?




File Organization.


Computers are used to manipulate data. Since it is best to organize all the data pertaining to a particular topic in the same place and this data needs to be stored for some period of time, it can be stored in a file.

Hence, a file is a collection of related data. Files can contain text (words, numbers, punctuation, etc), numbers, or computer programs, among other things. Some files (called text files) can be read and understood easily by humans, while others (called binary files) are formatted so the data they contain can be read quickly and easily by a computer.

The operating system provides a means for organising and manipulating the files.

Files can be organized on a computer by storing them in appropriate directories. For instance, we might have one directory for storing class assignments, another for storing letters, and yet another for games and such. Directories can also contain other directories, called subdirectories. thus we might break our letter directory into two subdirectories, one for personal letters and one for business letters. The directory above any subdirectory is referred to as the parent directory. Look at the directory 92data in the following diagram. The root directory is the parent directory and 92data is a subdirectory. 92data is also the parent of personal, and correspondingly, personal is a subdirectory of the 92data directory.




Directory trees.


Directory structures can be represented by a diagram called a directory tree (See diagram above). At the top of the tree is the root directory. In MS-DOS the root directory is designated by a backslash symbol ("\"). Log on to the system if you haven't already done so, and take a look at your screen prompt. It should look like:

H:\>

The "H:" is the name of the disk drive you are currently using. The first backslash after the disk name represents the root directory. When you log on, you will automatically be placed in your own directory, as indicated by the system prompt. This is referred to as your home directory. NOTE: the home directory is not the same as the current directory. Your home directory is always the same, but you can change your current directory in the course of a session.



Directory file listings.


For a start, you will want to be able to see what is in your directory. The DIR command will create a list of all the files in the current directory. Type

DIR

The message that appears should tell you no files were found. Since your account is new, and you haven't put any files in the directory, this would seem reasonable.


So, there are two ways you can now get files in your directory. One is to create them, the other, which is easier, is to copy them.

Copying a file.


You can copy a sample file from the library directory (J:\SF100) to your directory using the COPY command. Type the following:

COPY J:\SF100\FILE1.TXT FILE1.TXT

To understand what this did, consider the following. The COPY command looks like this:


COPY sourcefile destinationfile
The words in italics refer to generic file names and should NOT be typed in as written. The source file is the file to be copied and can either be a file in the current directory or another directory. The destination file is the new file and can also be a file in the current directory or another directory. So in the Copy command you have just used, the source file was a file called FILE1.TXT in another directory specified with a path (J:\SF100\) and the destination file was a file called FILE1.TXT in your own directory.
The path tells MS-DOS where to find the file in the directory structure. It specifies all the directories in the structure from a known location (either a drive root or the current directory), to the file wanted. In this case the path goes from the F drive root (J:\) down to the SF100 directory which contains the file to be copied.
Verify that the file was copied successfully be typing DIR. You should now see the file FILE1.TXT in the directory listing. Now make another copy of the file, but place it in the same directory as the source file. First, try typing:

COPY FILE1.TXT FILE1.TXT

This should make a second copy of the file, right?

But notice that this command generates the error message:

File cannot be copied onto itself

0 files copied

It makes sense when you think about it. You have to specify a destination file with a new name. Type



COPY FILE1.TXT FILE2.TXT

Because the destination file has a different name from the source file, the command should work properly now.






WARNING: if there already exists a file with the same name as your destination file, the existing file will be overwritten by the new one and its original contents lost. No error message will be given to warn you of this, so be careful you do not destroy an important file when using the COPY command.

To be sure you have grasped the Copy command, copy the file FILE1.TXT to a new file called "MYFILE.DAT"



Directory listings.


So far you have used the Dir command for seeing all the files in a directory. However, you can specify that you only want files meeting particular criteria listed. The command looks like this:
DIR filespec
NOTE: again the words in italics refer to a generic file name, and should NOT be typed in as written. In the case of the DIR command, the file specification (filespec) refers to the files you wish to look at. It can be left blank, in which case a listing of all the files in the current directory will be listed. When you want to look at only some of the files, you can specify this by means of a wildcard character, indicated by an asterisk "*". (see the DOS appendix for more on wildcards). For example, Type:

DIR *.TXT

This should produce a listing of only the files with the extension "TXT", generally considered to indicate a file containing human-readable text. Another example, type:



DIR FILE*

This will produce a listing of all the files with a name starting with "FILE" followed by an extension ("TXT", "DAT", "WPS", "WKS" etc).


You should also have noticed that the DIR command gives you more information than just what files are in a directory. Take the following example where you might see something like the following:

FILE1 TXT 128 11-30-93 10.23 am

1 File(s) 56923328 Bytes free

This indicates that there is one file in the directory, named "FILE1.TXT". The 128 indicates the number of bytes contained in the files, telling you how large the file is. One byte is roughly equivalent to one character. The remainder of the line gives the date and time the file was created. At the bottom of the directory listing is how much space is left on the whole disk.


NOTE: this is NOT how much empty space you have in your directory! For practical reasons, each user of the network is allowed only a certain amount of disk space so that one person does not take up the entire disk. As a result, you may run out of room in your account even though your directory listing says there are many millions of bytes available.
You've seen some file names in directory listings. In MS-DOS, filenames consist of two parts, the name proper, which can contain up to eight characters, and the extension, which contains up to three characters. These are the first two items on a line in a directory listing. The name distinguishes the file, and the extension tells what kind of file it is. There are several standard extension protocols. For example "TXT" indicates a text file, "DAT" indicates a data file, "WPS" indicates a Works Wordprocessing file, "etc.
Note: that when you write a file name, the name and the extension are joined together with a full-stop "." with no space between. When a file name appears in a directory listing as above, however, the file name and the extension are displayed separately, with no full stop between.

Showing a file on the screen.


Once you know what files you have, you may want to see what is in them. The TYPE command can be used to view a text file on the screen. The TYPE command looks like this:
TYPE filename
Where filename is the name of the text file you wish to see. Let's see how it works. Type the following command into the computer:

TYPE FILE1.TXT

Some text should appear on the screen in a readable form. Note however that it scrolls by too fast to read. This can be corrected with the MORE command. Type:



TYPE FILE1.TXT |MORE

This has the effect of breaking the text in the file into screen sized pieces, allowing you to read the text conveniently. (The key is <\> on most keyboards and may appear broken in two on the screen.)


NOTE: the TYPE command only works with text files! Binary files will appear as garbage, and viewing them on the screen can alter the settings on your computer.

Creating subdirectories.


As mentioned earlier, related files can be organised in subdirectories. You can create a subdirectory using the "MD" ("Make Directory") command in response to the MS-DOS prompt. The "MD" command looks like:
MD newdir
As before, the words in italics represent a generic directory name and should not be typed in as written. Substitute the name of the new directory to be created. This new directory will appear as a subdirectory in the current directory.
Use the MD command to create a directory called "MYDIR". While still in your home directory, type the following:

MD MYDIR

Confirm that it has been created by getting a directory listing. You should see the name of the new subdirectory in the directory listing. Notice that after the subdirectory name "MYDIR" a "

" appears instead of an extension, signifying that it is a directory and not a regular file.


As a new directory, MYDIR is empty. To put a file in the directory, type:

COPY FILE1.TXT \MYDIR\FILE1.TXT

Note the use of the path to specify that the destination file is in another directory.



Viewing directory Trees

A useful command that enables you to view the directory tree, is the TREE command. To see your directory tree, type:



TREE

You should see a tree diagram of your directories. If you wish to see what files you have in the directories and subdirectories, type;



TREE /F

The "/F" is known as a "switch", and you should get in the habit of placing a space between the command and the switches.



Changing directories.


The next step is to make the new subdirectory the current directory. When you log in, you will always be placed in your home directory. This is you current directory when you start. At times you may wish to work in another directory. You can change the current directory by using the "CD" ("change directory") command, which looks like this:
CD dirname
The words in italics represent the name of the directory to be changed to, and should not be typed as written. Type:

CD MYDIR

Note that the prompt has changed to look like:



H:\MYDIR>

The prompt is set up to show you which directory is the current directory. This way you will always know where you are currently in the directory structure. Look at the directory listing. You should see the file you copied into the subdirectory. Now type:



Dir H:\

This should show you the listing for the root directory, as you have specified the root with a path. Alternatively, you could use the DOS notation for parent directories. In each listing, at the top you will see a line with a directory named "." and another named "..". This is MS-DOS' way of following the directory structure. The "." refers to the current directory, and ".." to the parent directory. Type:



Dir ..

This should also give the directory listing for the root directory, which is the parent of MYDIR. The . .. notation will work with the other commands. Type:



CD ..

This will make the parent directory the current directory. Check the prompt and get a directory listing to verify that you are back in your home directory. Then make MYDIR the current directory again.



Renaming a file.


There are times when you want to give a file a new name without changing the contents. For example, a file may have been named incorrectly and the name must be changed to get the computer to do what you want. File names can be changed by means of the REN command, which has the following syntax:
REN oldname newname
The REN command takes an existing file, "oldname", and gives it a new name "newname". Try renaming the file in the MYDIR directory. Type the following:

REN FILE1.TXT JUNK.TXT

This will rename the file FILE1.TXT to JUNK.TXT. Get a directory listing to confirm this has worked. At some point you may forget the proper way to use the REN command and only give it one file name. No worries; you will simply get an error message like this:



Required parameter missing

No harm will be done to the system or your files. Try typing



REN RUBBISH.TXT

You should see the error message. It should also show that making mistakes on a computer is not disastrous (usually).



Deleting a file.


As you continue to use the computer, you will accumulate files which are no longer needed. To save space on the disk, it's a good idea to delete files you don't need any more, and you should try to make cleaning out redundant files a regular habit. This is done with the DEL command.

DEL filespec

This removes the file from the directory listing. Be careful! Once you delete a file there is no easy way to get it back. The information it contains will be lost, so use this command with care.
Some examples are:

DEL OLDFILE.TXT

This will delete the file OLDFILE.TXT.
Wildcards can also be used with the DEL command:

DEL *.OLD

DEL OLDFILE.*

The first example will delete all the files with the extension OLD, regardless of the file name. The second will delete all files with the name OLDFILE, regardless of the extension.






WARNING:. Here's a bad one:
DEL *.*

This command will delete all the files in your current directory. Because this could be disastrous, it will first ask you



Are you sure (Y/N)?

If you type N, it will stop without deleting anything. If you type Y it will go ahead and delete all the files in the directory. Be careful with this one, because you cannot retrieve deleted files.


Try the DEL command. First do a DIR command to view the files currently in the MYDIR directory. Then type:

DEL JUNK.TXT

Now do a DIR command. If all went well, the file JUNK.TXT should no longer be in the directory.



Deleting directories.


Change the current directory back to the root. The command to remove a directory is:
RD dirname
Where RD stands for `Remove Directory', and dirname is the name of the directory to be deleted. It is important that the directory to be deleted is empty. MS-DOS will prevent you from deleting any directory which contains files. Make sure that the MYDIR subdirectory is in fact empty. Then type:

RD MYDIR

Get a directory listing to confirm that the directory has been deleted.



Printing a file.


When you want to obtain a printout of a file (known as hard copy, as opposed to soft copy, which refers to files on a disk), you can use the PRINT command. This has the following syntax:
PRINT filename
As before, the word in italics refer to a generic file name and should not be typed in as written. To obtain a hard copy of the file FILE.TXT, type the following command:

PRINT FILE1.TXT

This will send a copy of the file to the printer. It may take a few minutes for the file to be printed, especially if many people are using the printer, so please be patient.




3. Disk Drives




Drive names.


Most of today's computers can be set up with more than one disk drive. The PCs in the laboratory do not use internal drives. Through the network they use several hard drives which are attached to the server. In MS-DOS, disk drives are identified by letter names. Take another look at the prompt.
H:\>
In this instance, the "H:" on the left side of the prompt is the name of the default drive. The operating system will look for files on this drive first.
Default drives. You can change the default drive to another by typing the name of the new drive followed by a colon. To change the default drive, type:
J:
Notice that the prompt has now changed to J:\> The default drive is now the J: drive. To change back to the H: drive, type.
H:
Notice that the prompt has changed back to what is was before,

You can change the default directory on another drive. While still in your home directory on the H: drive, type:


CD J:\SF100
Notice that you are still in the same directory on the same drive. But when you switch to the J: drive, you will automatically be in J:\SF100, the new default directory for that drive. Try this and examine the new default directory name.
Use the commands you have examined for changing between disks and directories, and for listing directory contents, to explore the directory structure on the J: drive.

4. Miscellaneous Commands.


To finish, here are a few commands which may be of use. First, make sure you are in your own root directory (H:\).
a) To find the current data or time, MS-DOS provides the DATE and TIME commands. Type

DATE

You should see a message like:



Current date is "Current date"

Enter new date (mm-dd-yy):_

If the current data displayed is wrong, correct it by typing the data in the format specified (month-day-year). Otherwise press . The TIME command works in a similar manner. Try it out.


b) Clearing the screen. Sometimes you may find your screen covered in garbage, or too crowded to comprehend in a straightforward way. To clear the screen, MS-DOS provides the CLS command. Type:

CLS

The screen should now be blank, except for the prompt in the top left-hand corner.


c) Setting the prompt. MS-DOS allows you to change the prompt to suit your own preferences. The prompt command looks like
PROMPT $character $character
Where $character can be any of the following:

$d The current date

$t The current time

$p The current directory

$g The > character

$l The < character

$q The = character

$b The Ý character

$$ The $ character

$h Backspace (erases a character written to the prompt)


The current prompt is set to $p$g. Try typing:

PROMPT $g$g

Now you should see the prompt as ">>". You can add things like the time to the prompt. This is handy as it will generally be right in front of you. Type



PROMPT $t$g

You will see that this gives the time far more precisely than most people will require. You can trim the value given by erasing some of the characters to the right, using backspace. Type



PROMPT $t$h$h$h$h$h$h$g

This should be a little easier to understand at a glance. Consider what his prompt command does:



PROMPT $d$h$h$h$h$h$h$h$h$h$h$t$h$h$h$h$h$h $p$g

Try a few of the combinations and see what happens. If you intend regularly using a different prompt, remember to include $p, so that you know at a glance what your current directory is.





[M H Verhaart] 25 June, 2016 [MSDOS.DOC]Page


Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©atelim.com 2016
rəhbərliyinə müraciət