\
What you absolutely have to know to do anything at a command prompt
it's absolutely all about paths, relativly speaking
Websters Desk Dictonary defines path as "1. A way or track made by footsteps.
2. A course: route". A path in computerese is a related concept,
but only if you think of yourself as a little duck that waddles along those
dotted lines you see in Windows Explorer. The dotted lines are all
the possible paths.
Absolute Paths
Absolute paths are absolute because no mater where you are, the directions
start at the root of the drive. In DOS and Windows, you specifiy
this by typing the drive letter at the begining. The following are
examples of absolute paths:
-
C:\Windows
-
A:\homework\cis18a\chapter1
-
S:\
Relative Paths
A realtive path is realtive to your current position. It tells the
duck to start wherever it's currently standing and follow directions from
there. To use a relative path you need to know where you started
and everything in between your startpoint and your endpoint. Relative
paths are most useful when just want to move up or down a directory.
(moving around is the next) Examples of relative paths include:
-
Favorite\Links (relative to C:\Windows)
-
cis18a\chapter1\partA (realtive to A:\homework)
The Path
The Path is the value in the path environmental variable. It holds
a list of places that the windows duck should look for programs (executables)
in. Why this is important will be discused in the executing
commands section. Each time you open a DOS prompt, it copies
(or inherits) the value of path from the global (master) set to it's own.
You can change the global path by editing autoexe.bat. You can also
change each individual DOS window's path by setting path equal to a new
value on the comand line. Here are a few examples of setting the
path:
-
path=C:\myprograms
-
path="C:\My Programs" (NOT the same place)
-
path="C:\My Programs";%path%; (tells the computer to look in C:\My
Programs, and then look in all the places that it used to look)
-
path=%path%;"C:\My Programs";"A:\homework"; (tells the computer to
add C:\My Programs and A:\homework to the list of places to look for executable
files)
Moving yourself around
At every command prompt I have ever seen, cd
will Change the Directory that your working in. It makes the little
duck fly. cd takes one argument
- the path of the directory you would like to be in. Using two periods
(..) as the argument is a shortcut to go 'up' one directory - and another
example of a realtive path.
Executing commands (aka running programs)
To execute a command (or run a program), you just type the command or programs
name. To windows, a command and a program are pretty much the same
thing. The .exe at the end of every program name is optional.
If the program takes arguments, you must know what they are and type them
after the command name. DOS always looks in the folder that your
currently in before looking along the path. So if your in the same
directory as the program you want to run, just type it's name. if
your not, type the path (and the program name) that will tell windows where
to find it. If the program is on the path, then you don't need to
do all that typing. You can just type the name of the program from anywhere.
examples of ways to run programs:
-
bin\javac (from the jdk folder)
-
javac (from anywhere if it in the path)
-
javac.exe (from the folder where javac.exe is located)
-
C:\jdk\bin\javac.exe (from anywhere)
Looking at the Stuff Stored in the directory
In MS-DOS, typing dir will show you what is in the directory that you are
in. If you want to view files in a differnt directory typ dir, a space,
and the path of the directory you want see the contents of. This
is an example of using a command (running a program) that takes arguments.