Presentation is loading. Please wait.

Presentation is loading. Please wait.

C OMP 110/401 W INDOWS C OMMAND I NTERPRETER Instructor: Prasun Dewan (FB 150,

Similar presentations


Presentation on theme: "C OMP 110/401 W INDOWS C OMMAND I NTERPRETER Instructor: Prasun Dewan (FB 150,"— Presentation transcript:

1

2 C OMP 110/401 W INDOWS C OMMAND I NTERPRETER Instructor: Prasun Dewan (FB 150, dewan@unc.edu)

3 2 W INDOWS C OMMAND I NTERPRETER

4 3 C OMMAND I NTERPRETER ? Interprets Command Lines Provides alternative to (OS and Application) GUIs

5 4 GUI A LTERNATIVE GUI Command Interpreter

6 5 W HY C OMMAND I NTERPRETER ? Command lines may be preferred to GUIs in some situations and by some people Some applications and OS’s do not come with GUIs and must be used through command interpreter java, javac, kindlegen Some think you do not know computers if you do not understand a command interpreter

7 6 C OMMAND L INE S YNTAX javac -d bin src\warmup\AGreeter.java cd warmup parameters Command = Command Line Command = Command Name Command = Command Line Command = Command Name

8 7 C LASSIFYING C OMMAND (N AMES ) Execute code built-into OS Internal cd Execute some application program installed on top of OS External javac Command interpreter does not know about external command names; so how does it run and interpret them?

9 8 R UNNING E XTERNAL C OMMAND : T OKENIZATION AND T WO -S TAGE C OMMAND I NTERPRETATION Name of an executable file javac -d bin src\warmup\AGreeter.java A sequence of parameters Command interpreter separates the command line into a sequence of units or tokens divided by “separators” ( spaces and tabs) It treats the first token as the name of an executable file, finds it and executes it It passes the remaining tokens to the newly executed program, which then interprets them One or more of the parameters may be file (and folder) names

10 9 C OMMAND I NTERPRETER S EARCHING FOR E XECUTABLE C OMMAND : F IRST I NTERPRETATION S TAGE It treats the first token as the name of an executable file, finds it and executes it

11 10 E XTERNAL P ROGRAM I NTERPRETING P ARAMETERS : S ECOND I NTERPRETATION S TAGE It passes the remaining tokens to the newly executed program, which then interprets it

12 11 T OKENIZATION D:\Program Files\Java\jdk1.7.0_11\bin\javac -d bin src\warmup\AGreeter.java First token = command-name

13 12 "D:\Program Files\Java\jdk1.7.0_11\bin\javac" -d D:\dewan_backup\Java\WarmupProject\bin AGreeter.java U SING Q UOTES FOR T OKENS WITH S PACES First token = command-name

14 13 H OW TO N AME F ILES ( AND F OLDERS ) One or more of the parameters may be file (and folder) names Files and folders are both often called files "D:\Program Files\Java\jdk1.7.0_11\bin\javac" -d D:\dewan_backup\Java\WarmupProject\bin AGreeter.java File Names

15 14 "D:\Program Files\Java\jdk1.7.0_11\bin\javac" -d D:\dewan_backup\Java\WarmupProject\bin AGreeter.java R ELATIVE /P ARTIAL VS. A BSOLUTE /F ULL N AMES Relative name Absolute name Shorter names but more complicated naming scheme Longer names but simpler naming scheme

16 15 L OCAL N AME OF F ILE / FOLDER “D:\Program Files\Java\jdk1.7.0_11\bin\javac" –d D:\dewan_backup\Java\WarmupProject\bin AGreeter.java Local Name A file or folder is always created within some parent folder to create a hierarchical file system The name given within the parent folder is called the local name of the file/folder

17 16 A BSOLUTE /F ULL N AME Names are separated by \ Gives the full “path” name, with each name taking isone level down in the folder hierarchy “D:\Program Files\Java\jdk1.7.0_11\bin\javac" –d D:\dewan_backup\Java\WarmupProject\bin AGreeter.java Local name of the target flile(folder) Preceded by Local name of its parent Preceded by Local name of its parent’s parent … … Drive name

18 17 D:\dewan_backup\Java\WarmupProject\bin T RAVERSING D OWN THE H IERARCHY D: dewan_backup Java src warmup AGreeter.java AGreeter.class warmup bin WarmupProject

19 18 R EDUCING E FFORT TO E NTER A BSOLUTE N AMES Copy Absolute Name from GUI and Paste into Command Line Edit Previously Entered Command Line

20 19 C OPY A BSOLUTE N AME FROM F OLDER B ROWSER GUI Click mouse to get full name CTRL + C

21 20 P ASTE INTO C OMMAND L INE Top border, Right menu  Edit  Paste

22 21 T EXT P ASTED AT C URRENT C URSOR P OSITION

23 22 U SE LEFT AND RIGHT ARROW K EYS TO CHANGE C URSOR P OSITION Cursor at start of line

24 23 C AN INSERT OR D ELETE AT C URSOR P OINT “ inserted at start of line

25 24 R ELATIVE N AME Relative to current directory (or folder) Relative to folders in System Path

26 25 C URRENT D IRECTORY Each command interpreter is associated with a current directory or folder name, parts of the Windows prompt Build-in cd command can be used to change the current directory to some other directory on the same drive Initial folder is home directory of logged in user Build-in drive command can be used to change drive

27 26 C HANGING D RIVES Command = Drive Name: Case does not matter in drive file names on Windows

28 27 C HANGING F OLDER WITHIN D RIVE : CD C OMMAND cd Current directory 

29 28 N AME R ELATIVE TO C URRENT D IRECTORY Relative to current directory (or folder) Given current directory with absolute name: a Relative name: r = a file with absolute name: a\r

30 29 R ELATIVE N AME Relative to single current directory (or folder) Relative to multiple folders in System Path “D:\Program Files\Java\jdk1.7.0_11\bin\javac" –d D:\dewan_backup\Java\WarmupProject\bin AGreeter.java Can be used in both command names and file parameters Used only in command names

31 30 S ETTING S YSTEM P ATH : S YSTEM P ROPERTIES

32 31 S ETTING S YSTEM P ATH : A DVANCED S YSTEM S ETTINGS

33 32 S ETTING S YSTEM P ATH : E NVIRONMENT V ARIABLES

34 33 S ELECT P ATH S YSTEM : S ELECT P ATH V ARIABLE AND E DIT

35 34 S ELECT P ATH S YSTEM : A DD F OLDER TO P ATH AFTER S EMICOLON D:\Program Files\Java\jdk1.7.0_11\bin\javac No need for quotes because of ;

36 35 R EUSING C OMMANDS : C OMMAND H ISTORY Want to execute (portion of) a command in history Use up and down arrow keys to reuse commands in history

37 36 R EUSING C OMMANDS : U P A RROW D ISPLAYS P REVIOUS E DITABLE C OMMAND First Up-Arrow shows last command

38 37 R EUSING C OMMANDS : U P A RROW D ISPLAYS P REVIOUS E DITABLE C OMMAND Second Up Arrow shows second last command

39 38 R EUSING C OMMANDS : E NTER E XECUTES (P OSSIBLY E DITED ) P REVIOUS C OMMAND Enter Could have edited command History particularly useful if absolute files names entered

40 39 D:\dewan_backup\Java\WarmupProject\bin M ORE ON N AMES : T RAVERSING D OWN THE H IERARCHY D: dewan_backup Java src warmup AGreeter.java AGreeter.class warmup bin WarmupProject

41 40..\..\bin T RAVERSING U P ( AND D OWN ) THE H IERARCHY D: dewan_backup Java src warmup AGreeter.java AGreeter.class warmup bin WarmupProject Current Directory.. Name denoting the parent Target Directory

42 41 U SE OF..

43 42. N AMING C URRENT D IRECTORY D: dewan_backup Java src warmup AGreeter.java AGreeter.class warmup bin WarmupProject Current Directory The current directory A la this in Java

44 43 U SE OF. Current directory

45 44 NAMING R OOT F OLDER ON D RIVE D: dewan_backup Java src warmup AGreeter.java AGreeter.class warmup bin WarmupProject \ D: Changes drive, not directory within drive

46 45 C OMPLETING F ILE N AME T OKEN Hit tab

47 46 C OMPLETING F ILE N AME T OKEN Hit tab to complete token if known to application cmpleting Should choose unique prefix

48 47 S AVING I NTERACTION Input

49 48 M ARKING T EXT

50 49 M ARKING T EXT Drag mouse to select text

51 50 C OPY T EXT This text can now be pasted anywhere

52 51 O UTPUT R EDIRECTION Input Echoed Input of “Ca va” command Command > File Output of Command goes to File rather than the command window

53 52 I NPUT R EDIRECTION Echoed input from file Input for “Buon Girono Command Command < File Input of Command comes from File rather than the command window

54 53 P IPE Command1 | Command2 Output of Command1 becomes input of Command2

55 54 GUI A LTERNATIVE : D IR C OMMAND

56 55 GUI A LTERNATIVE : T YPE C OMMAND

57 56 GUI A LTERNATIVE : E RASE C OMMAND

58 57 GUI A LTERNATIVE : M KDIR C OMMAND

59 58 W ILD C ARD : *

60 59 W ILD C ARD : *

61 60 P ARTIAL W ILD C ARD AND F IND (P IPED )

62 61 I PCONFIG

63 62 PING

64 63 S ORT (P IPED )

65 64 F IND (P IPED )

66 65 S TARTING S EPARATE C OMMAND I NTERPRETER

67 66 E XTRA S LIDES

68 67 S TARTING A NOTHER C OMMAND I NTERPRETER IN S AME W INDOW AND E XIT

69 68 C OMMAND I NTERPRETER ? Interprets Command Lines Provides alternative to (OS and Application) GUIs

70 69 W HY C OMMAND I NTERPRETER Command lines may be preferred to GUIs Some applications and OS’s do not come with GUIs and must be used through command interpreter java, javac, kindlegen

71 70 GUI A LTERNATIVE GUI Command Interpreter Command interpreters came first

72 71 C OMMAND N AME R ELATIVE TO F OLDER IN P ATH

73 72 A DVANCE

74 73 R ELATIVE N AME Relative to current directory (or folder) Relative to folders in System Path “D:\Program Files\Java\jdk1.7.0_11\bin\javac" –d D:\dewan_backup\Java\WarmupProject\bin AGreeter.java Can used in both command names and file parameters Used only in command names

75 74 R ELATIVE N AME : G OING B ACKWARD A.. After some directory D refers to the parent of the D Given current directory with absolute name: d Relative name:... denotes a file with absolute name: d\f Relative name: src\warmup\AGreeter.java denotes a file with absolute name “ D:\dewan_backup\Java\WarmupProject>“\ src\warmup\AGreeter.java Given current directory with absolute name: “ D:\dewan_backup\Java\WarmupProject>"

76 75 … Relative to current directory (or folder) Given current directory with absolute name: d Relative name: f denotes a file with absolute name: d\f Relative name: src\warmup\AGreeter.java denotes a file with absolute name “ D:\dewan_backup\Java\WarmupProject>“\ src\warmup\AGreeter.java Given current directory with absolute name: “ D:\dewan_backup\Java\WarmupProject>"

77 76 R ELATIVE /P ARTIAL VS. A BSOLUTE /F ULL N AMES javac -d bin src\warmup\AGreeter.java D:\dewan_backup\Java\WarmupProject\src\warmup>"D:\Program Files\Java\jdk1.7.0_11 \bin\javac" -d D:\dewan_backup\Java\WarmupProject\bin AGreeter.java D:\Program Files\Java\jdk1.7.0_11 \bin\javac" -d D:\dewan_backup\Java\WarmupProject\bin AGreeter.java

78 77 T OKENIZATION D:\dewan_backup\Java\WarmupProject\src\warmup>"D:\Program Files\Java\jdk1.7.0_11 \bin\javac" -d D:\dewan_backup\Java\WarmupProject\bin AGreeter.java D:\dewan_backup\Java\WarmupProject\src\warmup>D:\Program Files\Java\jdk1.7.0_11 \bin\javac -d D:\dewan_backup\Java\WarmupProject\bin AGreeter.java First token = command-name

79 78 U SING Q UOTES TO S EPARATE T OKENS D:\dewan_backup\Java\WarmupProject\src\warmup>"D:\Program Files\Java\jdk1.7.0_11 \bin\javac" -d D:\dewan_backup\Java\WarmupProject\bin AGreeter.java First token = command-name

80 79 GUI A LTERNATIVE GUI Command Interpreter Command interpreters came first

81 80 T OKENIZATION D:\dewan_backup\Java\WarmupProject>D:\Program Files\Java\jdk1.7.0_11\bin\javac - d bin src\warmup\AGreeter.java First token = command-name

82 81 R ELATIVE N AME : G OING F ORWARD Relative to current directory (or folder) Given current directory with absolute name: d Relative name: f denotes a file with absolute name: d\f Relative name: src\warmup\AGreeter.java denotes a file with absolute name D:\dewan_backup\Java\WarmupProject>\ src\warmup\AGreeter.java Given current directory with absolute name: D:\dewan_backup\Java\WarmupProject>

83 82 GUI A LTERNATIVE GUI Command Interpreter Command interpreters came first

84 83 C LASSIFYING C OMMAND -N AMES Identify code built-into OS Internal cd Identify some application program installed on top of OS External javac Command interpreter does not know about external command names; so how does it run and interpret them?

85 84 D:\dewan_backup\Java\WarmupProject\src\warmup>"D:\Program Files\Java\jdk1.7.0_11 \bin\javac" -d D:\dewan_backup\Java\WarmupProject\bin AGreeter.java R ELATIVE /P ARTIAL VS. A BSOLUTE /F ULL N AMES Relative name Absolute name Shorter names but more complicated naming scheme Longer names and simpler naming scheme

86 85 H OW TO N AME F ILES ( AND F OLDERS ) javac -d bin src\warmup\AGreeter.java One or more of the parameters may be file (and folder) names File names Files and folders are both often called files

87 86 F ILE / FOLDER H IERARCHIES AND L OCAL N AMES D: dewan_backup Java src warmup AGreeter.java AGreeter.class warmup bin WarmupProject

88 87 C OMPLETING F ILE N AME Enter Could have edited command History particularly useful if absolute files names entered

89 88 R EDIRECTING O UTPUT Echoed input Input Command < File Input of Command comes fromFile rather than the command window

90 89.. T RAVERSING U P ( AND D OWN ) THE H IERARCHY D: dewan_backup Java src warmup AGreeter.java AGreeter.class warmup bin WarmupProject

91 90 O UTPUT R EDIRECTION Input Echoed Input Command > File Output of Command goes to File rather than the command window

92 91 I NPUT R EDIRECTION Echoed input from file Input Command < File Input of Command comes from file rather than the command window


Download ppt "C OMP 110/401 W INDOWS C OMMAND I NTERPRETER Instructor: Prasun Dewan (FB 150,"

Similar presentations


Ads by Google