Instructor: Prof. Michael P Harris ITSC 1405 – Intro to PC Operating Systems Chapter 2 Command Syntax CHAPTER 2 Command Syntax— Using the DIR Command with Parameters and Wildcards LECTURE NOTES CHAPTER OUTLINE Learning Activities Slides 2-9 CHAPTER OVERVIEW Will learn to read a syntax diagram and explain Chapter Overview duplicated in the the function of each part of the diagram. PowerPoint slides. Will learn some basic commands, their syntax, After completion of lecture, suggest to and how to make commands more specific. students that they review Objectives and Will be able to define prompts and explain how Outcomes found on first page of chapter as they are used. a check to see if they have mastered The purpose and function of defaults will be concepts. explained. Will learn how to change the default drive and directory. Will learn how to use subdirectories and wildcards with the DIR command. The purpose and function of redirection will be explained and then will learn how to redirect the output of the DIR command to a file or a printer. Will learn how to use the Online Help feature. COMMAND SYNTAX Command Syntax All languages have rules for speaking and writing. Syntax (word order) and punctuation of a language is important. Computers use language that consists of vocabulary, syntax, and punctuation. SECTION 2.1 (p. 40) Slides 10-12 User communicates with computer by using language that computer understands. Command syntax is the language, punctuation, and order needed to execute a command properly. Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line, Instructor’s Manual Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1 Page 1 Instructor: Prof. Michael P Harris ITSC 1405 – Intro to PC Operating Systems Commands. Similar to verbs. Action you wish to take. GUI in Windows - still syntax and rules. Icon that points to a program based on rules of syntax. An error message of “Bad command or file name” is computer saying, I don't understand. Chapter 2 Command Syntax Discussion Question (1) - Define command syntax. Discussion Question (2) - Why is syntax important when using a command? WHAT ARE PARAMETERS? What are Parameters? Provide information to modify/qualify command. Some commands. Require parameters. Have optional parameters - used for special purposes. Do not use parameters. Types of parameters. Variable parameters = user supplies value to command. Fixed parameters = cannot change fixed value (must use value provided). Parameters added to make action of command more specific. SECTION 2.2 (pp. 40-41) Slides 13-16 READING A SYNTAX DIAGRAM Reading a Syntax Diagram. Using DIR. First entry is always the command. Must be exact. Next parameters. Brackets - parameter is optional. Never key in brackets. N0 required/mandatory parameters for DIR. DIR syntax – See Power Point slide # SECTION 2.3 (p. 41) Slides 17-18 USING FIXED PARAMETERS WITH THE DIR COMMAND Using Fixed Parameters with the DIR Command Discussion Question (3) - Define parameters. Discussion Question (4) -What is the difference between a variable and a fixed parameter? Use analogies. - Vocabulary (commands). - Punctuation - Syntax (order). Discussion Question (5) - How would you use a syntax diagram? Why is the diagram important? SECTION 2.4 (pp. 41-42) Slides 19-22) Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line, Instructor’s Manual Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1 Page 2 Instructor: Prof. Michael P Harris ITSC 1405 – Intro to PC Operating Systems DIR uses optional parameters. Optional parameters (/W and /P are fixed). Controls how directory is displayed. /W = wide display. /P = pause or paged display. With new versions rules do not change. DIR has both optional and fixed parameters. Slashes must be keyed in, brackets never. When using DIR command by itself, files scroll by so quickly they cannot be read. Use /P parameter to display one screen of information at a time. Must respond to prompt before another screen of information will appear. ACTIVITY—USING FIXED PARAMETERS WITH THE DIR COMMAND Using Fixed Parameters with the DIR Command Note: Whenever text refers to ACTIVITIES DISK – use working copy made in Chapter 1 labeled “ACTIVITIES DISK – Working Copy" Activity steps. Boot system/Open Command Prompt window Key in: CD \ then Key in: CLS Insert “ACTIVITIES Disk – Working Copy” in Drive A and make A: default drive. Key in: DIR /P Press <Enter> 3 times, and/or until reach end of display. Key in: DIR /W Key in: DIR /P /W Return to system prompt Activity completed. USING FILE NAMES AS VARIABLE PARAMETERS Using File Names as Variable Parameters /P and /W are optional fixed parameters for DIR. Chapter 2 Command Syntax Fixed parameter referred to as switch and begins with the /. Discuss. - Difference between slash/backslash. - Why /P more efficient than using <Pause> or <Ctrl> + S keys. Reiterate any special lab instructions. If system varies from text refer to configuration table in Chapter 1.6. SECTION 2.5 (pp. 42-46) Slide 23 Any special lab instructions? Delimiter. - / slash. - Signals one thing ending and another beginning. - Forward slash (/) used only with fixed parameters. Mention that there is no space between / and P and / and W. Discussion Question (6) - Name two parameters that can be used with the DIR command. Explain why you would use the parameters. Discussion Question (7) - Define delimiters. Give an example of a delimiter. SECTION 2.6 (pp. 47-48) Slides 24-30 Naming conventions same in Windows XP as in Windows 2000. Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line, Instructor’s Manual Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1 Page 3 Instructor: Prof. Michael P Harris ITSC 1405 – Intro to PC Operating Systems Another parameter (name of file) can be used with DIR command. File naming review. Files formally called file specifications. File specifications broken into two parts: File name. File extension. Conventions for naming files: All files in a directory (subdirectory) must have unique names. File names are mandatory. May be less than but no more than 256 characters long. File extensions are usually three characters long. The following characters are illegal and may NOT be used in a file name: \ / : * ? < > | All other characters, including periods and spaces, are legal in Windows file names. File names should reflect subject of files. File extensions usually given by application creating the file. Many older 16-bit application packages (pre Windows 95) Cannot deal with long file names, spaces or periods in file names. Follow older DOS rules: 8 characters in name and 1 to 3 characters in optional extension. Some files on Internet adhere to older DOS rules. DIR syntax using /P or /W: DIR [drive:][path][filename] [/P] [/W] Filename in brackets - is a variable optional parameter. - plug in value or name of file. In some syntax diagrams, you will see [filename[.ext]] - .ext in brackets as is part of file name syntax. Chapter 2 Command Syntax Parameters are specific to each command. When giving file name give both parts - file name and file extension. Even though spaces and long names can be used, it’s better to keep file names short and concise. Older DOS rule called 8.3 rule. Dot (delimiter) only used between file name and file extension. Discussion Question (8) - Define file specifications. Discussion Question (9) - How do you separate a file name and a file extension? Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line, Instructor’s Manual Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1 Page 4 Instructor: Prof. Michael P Harris ITSC 1405 – Intro to PC Operating Systems Chapter 2 Command Syntax File may not have an extension. If file has extension - must include it. - no spaces between file name and extension. Delimiter used between file name and extension is dot (.) When using DIR command, you will not see period or dot between file name and file extension on screen. - Directory display, dot indicated by spaces. ACTIVITY—USING A FILE NAME AS A VARIABLE PARAMETER Using a File Name as a Variable Parameter At command line with prompt A:\> . Activity steps. Key in following commands: Continue pressing <Enter> key until you reach end of display. Activity completed. DIR VENUS.TXT DIR NOFILE.TXT DIR STEVEN.FIL C:\WINDOWS\SYSTEM32\DISKCOPY. COM DIR LONGFILENAME DDIR LONGFILENAME.EXTENSION DIR Sandy and Patty.txt DIR “Sandy and Patty.txt” DIR /X/P SECTION 2.7 (pp. 48-52) Slide 31 Discuss all parts of display with each command. System message – File Not Found (Error message). Can enter more than one file specification with DIR command. Can enter more than one parameter at one time when using DIR. Can use DIR command with long file name. File extension can have more than three characters. Quotation marks used to treat long file name with spaces in it as one unit. Long file name has name that adheres to 8.3 naming convention (name called an alias). /X parameter - used to see 8.3 names. 8.3 name derived from LFN by removing spaces, taking first 6 characters of file name and adding a tilde (~) and a number. Good idea to keep file names short/concise Less chance of making typo LFNs take up needed room on floppies. Discussion Question (10) – What is used to separate a file specification from a path name? Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line, Instructor’s Manual Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1 Page 5 Instructor: Prof. Michael P Harris ITSC 1405 – Intro to PC Operating Systems COMMAND LINE EDITING Command Line Editing Can reuse last command keyed in without re-keying it. Use <F1> to recall command line one letter at a time. Use <F3> to recall entire command line. SECTION 2.8 (p. 53) Slides 32-35 Discussion Question (10) – If you keyed in 10 commands and wanted to reuse a command previously keyed in, what could you do? See PowerPoint slide # for Editing Keys Command Summary. ACTIVITY—USING COMMAND EDITING Using Command Editing “ACTIVITIES Disk—Working Copy” is in Drive A with A: \> displayed. Activity steps. Key in DIIR/P Chapter 2 Command Syntax Press <F1> key twice Cancel command and clear memory of command line editor. Key in the following: CLS DIR FRANK.FIL DIR VEN.99 VOL DIR JUP.99 DIR ORION.NEB DIR DRESS.UP RIGHT.UP Press following keys. Up arrow key 2 times. Down arrow key once. <Ctrl> + <left Arrow> one time. <Insert> key At cursor key, key in: FILE3.FP. Press following keys: <Enter> then up arrow key twice. <Ctrl> + left cursor one time. Key in: FILE3.FP Press <F7>. Press <F9>/number that appears before DIR VEN>99 (in this case 2) Press <Enter>/<Esc>/D/<F8>. Press <Esc>/<Alt> + <F7> Press up arrow key once. Close Command Prompt window. SECTION 2.9 (pp. 54-57) Slide 36 Discuss results of editing key used in this activity. Editing keys can be used to recall and edit commands. Overstrike mode – replaces each character you key in data. Insert mode –“inserting data” at the cursor. Use shortcut (<Esc> key) to delete line quickly. Can search for previously entered command by keying in first letter/s of command you are interested in. Activity completed. Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line, Instructor’s Manual Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1 Page 6 Instructor: Prof. Michael P Harris ITSC 1405 – Intro to PC Operating Systems Chapter 2 Command Syntax DRIVES AS DEVICE NAMES Drives as Device Names Device is a place to read information from or write information to. Disk drives have device names (followed by a colon) assigned so Windows knows where to read or write. Drive names on stand-alone computers are typically A:, B:, or C:. If on network, disk drive letters can vary. Other common devices to read information from or write information to: Keyboard. Printer. Monitor. SECTION 2.10 (pp. 57-58) Slides 37-38 DEFAULTS Defaults Implied instructions. When you don't tell the computer what to do, it makes assumptions. Computer assumptions are called defaults. When prompt is A:> Tells you A is the default drive. Any command given will assume the default unless otherwise specified. The displayed prompt is the default, designated, or logged drive. In Explorer default drive indicated on title bar. SECTION 2.11 (p. 58) Slides 39-=40 “ACTIVITIES Disk” in Drive A. Activity steps. Open Command Prompt window. Key in the following: A: DIR Discussion Question (11) - What is the function and purpose of a device? Default - very important concept. Value used unless another value is specified. Default drive is drive commands will operate on unless other information is given. Remind students that these rules apply to application software as well. Default drive, designated drive, and logged drive are the same. ACTIVITY—WORKING WITH DEFAULTS Working with Defaults Disk drive is an example of a device. Discuss what drive names are in the lab. First floppy disk is called A: First hard disk is called C: Discussion Question (12) - Explain the function and purpose of the default drive. Discussion Question (13) - How can you tell which drive is the default drive? SECTION 2.12 (pp. 58-62) Slide 41 “Shelling out to DOS” or “shelling out to command line” – when open Command Prompt window and changed default drive to A. Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line, Instructor’s Manual Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1 Page 7 Instructor: Prof. Michael P Harris ITSC 1405 – Intro to PC Operating Systems DIR A: C: CD \ DIR A: DIR HELLO.TXT DIR A: HELLO.TXT Activity completed. A BRIEF INTRODUCTION TO SUBDIRECTORES—THE PATH A Brief Introduction to Subdirectories—The Path Subdirectories are used primarily on hard disks. Allows grouping of files by type. Allows disk to be divided into smaller, more manageable sections. Windows refers to subdirectories as folders. Graphically represented with folder icons. In command line shell folders referred to as directories and subdirectories. Subdirectories can contain other subdirectories. In C:\MYFILES\REPORTS\REP.DOC First backslash (\) always represents root directory. The other backslashes are delimiters separators between elements in the path. (elements being subdirectories). Every disk comes with one directory named by operating system. Other subdirectories are created and named by user. Rules for naming are same as for naming files. Do not usually have extensions. Subdirectory name is called the path name. Path is route followed by operating system to locate, save, and retrieve a file. When you see "path" in a syntax diagram substitute the directory name or names. Chapter 2 Command Syntax If on network hard drive letter may not be C: Discuss using default vs. giving drive to be searched. DIR A: HELLO TXT – very clear request – drive designator preceded file name. SECTION 2.13 (pp. 62-63) Slides 42-49 Subdirectories used with large storage media, i.e., RW-CDs or Zip disks. Technically, only one directory (the root), all others are subdirectories. Terms "directory" and "subdirectories" used interchangeably in this text. Subdirectories can be used on any disk hard or floppy. Directory/subdirectory names cannot be letters of the alphabet. Letters of the alphabet are reserved for disk drive names. Forward slashes (/) for parameters. Backslashes (\) for directories. Use analogy of file cabinet (disk) and drawer (subdirectory). Discussion Question (14) - Define default subdirectory. Discussion Question (15) - How can you tell which directory is the default subdirectory? Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line, Instructor’s Manual Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1 Page 8 Instructor: Prof. Michael P Harris ITSC 1405 – Intro to PC Operating Systems ACTIVITY—USING PATH WITH DIR Using Path with the DIR Command “ACTIVITIES Disk-Working Copy” in Drive A. C:\> is displayed. Activity steps. Key in: DIR A: DIR A:\DATA DIR A:\DATA\THIN.EST SECTION 2.14 (pp. 63-65) Slide 50 <DIR> - indicates subdirectory listing. Use of backslash as delimiter for path names. Backslash. First \ is the root directory. Other \’s are delimiters. Activity completed. CHANGING DEFAULTS Changing Defaults Default drives can be changed so OS automatically uses drive displayed on screen as default drive. Text assumes C:\WINNT\SYSTEM32. Be sure filled out information on Configuration Table in Chapter 1.6. ACTIVITY—CHANGING THE DEFAULT DRIVE Changing the Default Drive “ACTIVITIES Disk—Working Copy” in Drive A. C: \> is displayed. Activity steps. Change default to A:\> Key in: DIR DISKCOPY.COM DIR C:\DISKCOPY.COM Chapter 2 Command Syntax DIR C:\WINDOWS\SYSTEM32\DISKCOPY.COM Activity completed. SECTION 2.15 (p. 65) Slide 51 Command line is not case sensitive. Inform students of any differences in your lab. Prompt displayed on screen could look different from textbook prompt. SECTION 2.16 (pp. 65-67) Slide 52 Stress importance of noticing default drive. Emphasize that C:\ is major subdirectory for most users. Discussion Question (16) - What steps must be done to change the default drive? Why would you change the drives? Discussion Question (17) – What does A:\> mean? CHANGING DIRECTORIES Changing Directories SECTION 2.17 (p. 67) Default directory can be changed as easily as Slides 53-55 default drive. Discussion Question (19) – What steps must be Once default drive is established can done to change a directory? Why would you establish default directory. change a directory? - Do not need to specify path as default is specified. To change directory, key in CD (change directory), followed by the directory (path) name. Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line, Instructor’s Manual Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1 Page 9 Instructor: Prof. Michael P Harris ITSC 1405 – Intro to PC Operating Systems If you key in CD with no parameters, the directory that is current is the default directory. To change drives at same time as you change directories, use /D parameter. ACTIVITY—CHANGING DIRECTORIES Changing Directories “ACTIVITIES Disk—Working Copy” is in Drive A. A: \> is displayed. Activity steps. Key in the following: Chapter 2 Command Syntax C: CD CD \WINDOWS\SYSTEM32 DIR DISKCOPY.COM CD CD /D A:\DATA DIR CD \ Activity completed. GLOBAL FILE SPECIFICATIONS: WILDCARDS, THE ?, AND THE * Global File Specifications: Wildcards, (?, and *) Allow you to work with a group of files. Formally called global file specifications. Informally called wildcards. * represents a group of characters. ? represents a single character. Techniques used here will also apply in Search in the GUI (in Windows Desktop). SECTION 2.18 (pp. 67-69) Slide 56 CD keyed in alone will display current default directory. CD followed by path (directory name) will change default directory. CD \ will always return to root directory. First backslash always means root directory and other backslash is a delimiter. SECTION 2.19 (pp.69-70) Slides 57-58 DIR command & file name find one specific file. Global file specifications to find group of files. Use analogy of playing cards where joker can stand for another card of your choice. ACTIVITY—DIR AND WILDCARDS DIR and Wildcards “ACTIVITIES Disk—Working Copy” in Drive A:. A: \> is displayed. Activity steps. Key in: C: Key in: CD \WINDOWS\SYSTEM32 Key in the following: DIR G DIR G*.* Discussion Question (20) – What is the significance of the first backslash in a command? Discussion Question (20) - Define global file specifications. SECTION 2.20 (pp. 70-75) Slide 59 Stress importance of knowing directory where the files are located. Emphasize that even though DIR G will find files, should get used to using DIR G*.* Examples of using *. Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line, Instructor’s Manual Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1 Page 10 Instructor: Prof. Michael P Harris ITSC 1405 – Intro to PC Operating Systems DIR *.SYS DIR A:\*.TXT DIR A:\?????.TXT DIR A:\EXP*.* DIR A:\EXP99*.* DIR A:\EXP??JAN.* CD \ Activity completed. REDIRECTION Redirection Keyboard = standard input device. Screen (monitor) = standard output device. Redirection tells OS to redirect output somewhere else. Usually to file or printer. Printer. Must be local, not network printer. Works only with commands that write to standard output. Redirection works with DIR. Does not work with all commands. Syntax is: COMMAND > DESTINATION Space req. on both sides of >. ACTIVITY—REDIRECTING OUTPUT TO A FILE Redirecting Output to a File “ACTIVITIES Disk—Working Copy” in Drive A. C:\ is displayed. Activity steps. Key in: A: Key in: DIR *.NEW Key in: DIR *.NEW > MY.HW Key in: DIR MY.HW Chapter 2 Command Syntax Compare using * and ? If group has common file extension .SYS can display files using wild cards *.SYS Discussion Question (22) - How are wildcards used? Discussion Question (22) - If you see C:\WINNT\SYSTEM32> on the screen, what does it mean? SECTION 2.21 (pp. 75-76) Slides 60-62 Must use correct device name for printer. - PRN for default printer - LPT1, LPT2, LPT3 for printer attached to specific port. If using network printer must know name of network printer. Can name file. Devices have specific names. Discussion Question (24) - What is the purpose and function of redirection? SECTION 2.22 (pp. 76-77) Slide 63 Discuss how to deal with write-protected disks. Remind students that redirection is an “instead of” procedure. Activity completed. REDIRECTING OUTPUT TO THE PRINTER Redirecting Output to the Printer Can redirect output of DIR command to printer to get a hard copy. SECTION 2.23 (pp. 77-78) Slides 64-65 Review how disk drives are named. Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line, Instructor’s Manual Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1 Page 11 Instructor: Prof. Michael P Harris ITSC 1405 – Intro to PC Operating Systems Printer device name is PRN, LPT1, LPT2, and sometimes LPT3. PRN and LPT1 are usually synonymous. Must know network printer name to redirect to network printer. ACTIVITY—REDIRECTING THE OUTPUT TO THE PRINTER Redirecting the Output to the Printer Can this activity be done in the lab? “ACTIVITIES Disk—Working Copy” in Drive A. A: \> is default. Printer on. Activity steps. Key in: DIR *.TXT Key in: DIR *.TXT > PRN. Activity completed. GETTING HELP Getting Help Prior to DOS 5.0, was HELP in manual. Reference manual is called documentation. In DOS 6.0 and above, documentation found more online than in written form. For procedures/methods used in Windows GUI, use Help choice on Start menu. May get help on command line commands in GUI help. For help with command and syntax within DOS environment. Key in name of command followed by a space, a forward slash and question mark. Use HELP followed by command name. Commands and syntax listed in Appendix B. Chapter 2 Command Syntax Any special printing procedures in lab? Difference between numeral one and letter l. SECTION 2.24 (pp. 78-79) Slides 66-67 NOTE: - Are there special lab instructions? - Is this a Read-only activity? - Need local printer to do this activity.Unless your lab has additional instructions. Redirection is an “instead of” procedure. Hardware solutions – manipulate hardware to get desired results. --Done if page not ejected from local printer. SECTION 2.25 (pp. 79-80) Slides 68-70 Paper documentation still useful, i.e., if cannot boot system, what do you do? For procedures/methods in Windows GUI – good database info accessed via HELP choice on Start Menu. Discussion Question (25) - What would you do if you forgot the parameter for a wide DIR display? Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line, Instructor’s Manual Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1 Page 12 Instructor: Prof. Michael P Harris ITSC 1405 – Intro to PC Operating Systems ACTIVITY—GETTING HELP WITH A COMMAND Getting Help with a Command ACTIVITIES Disk—Working Copy” in Drive A. Default drive/directory is A: \>. Activity steps. Key in following commands: DIR /? DIR /ON DIR /O-N DIR /S DIR /BLP DIR /B /L /P Press <Enter> until end of display is reached. Key in: EXIT Initiate and complete Windows shut-down procedure. Chapter 2 Command Syntax SECTION 2.26 (pp. 80-84) Slide 71 Review. - Commands – verbs OS acts upon. - Use of mouse. - Parameters available with DIR command. Activity completed. Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line, Instructor’s Manual Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1 Page 13