Chapter 2: Getting the Most from the Command Line

 < Day Day Up > 



Overview

The command shell provides a powerful environment for working with commands and scripts. As discussed in the previous chapter, you can run many types of commands at the command line, including built-in commands, Windows utilities, and applications with command-line extensions. Regardless of source, every command you’ll use follows the same syntax rules. These rules state that a command consists of a command name followed by any required or optional arguments. Arguments can also use redirection to specify the sources for inputs, outputs, and errors.

When you execute a command in the command shell, you start a series of events that are similar to the following:

  1. The command shell replaces any variables you’ve entered in the command text with their actual values.

  2. Multiple commands that are chained or grouped, and passed on a single line, are broken into individual commands, separated into command-name and related arguments. The individual commands are then processed.

  3. If the command name has a file path, the command shell uses this path to find the command. If the command cannot be found in the specified location, the command shell returns an error.

  4. If the command name doesn’t specify a file path, the command shell tries to resolve the command name internally. A match means that you’ve referenced a built-in command that can be executed immediately. If no match is found, the command shell looks in the current directory for the command executable, and then searches the command path for the command executable. If the command cannot be found in any of those locations, the command shell returns an error.

  5. If the command is located, the command is executed using any specified arguments, including those that specify the inputs to use. Command output and any errors are written to the command window or to the specified destinations for output and error.

As you can see, many factors can affect command execution, including command path settings, redirection techniques used, and whether commands are chained or grouped. In this chapter, we’ll use this breakdown of command execution to help you get the most out of the command shell. Before we dive into those discussions, however, let’s look at special considerations for starting the command shell and introduce the concept of nesting command shells.



 < Day Day Up > 



Microsoft Windows Command-Line Administrator's Pocket Consultant
MicrosoftВ® WindowsВ® Command-Line Administrators Pocket Consultant
ISBN: 0735620385
EAN: 2147483647
Year: 2004
Pages: 114

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net