Understanding the Need for Command Line Applications
Many administrators today work with graphical tools. However, the graphical tools sometimes have
problems — perhaps they’re slow or they don’t offer a flexible means of accomplishing a task. For this
reason, good administrators also know how to work at the command line. A command line applica-
tion can accomplish with one well-constructed command what a graphical application may require
hundreds of mouse clicks to do — for example, the FindStr utility that lets you find any string in any
file. Using FindStr is significantly faster than any Windows graphical search application and always
provides completely accurate results. In addition, there’s that option of searching any file — many
search applications skip executables and other binary files. Give it a try right now. Open a command
prompt, change directories to the root directory (
CD \
), and type
FindStr /M /S “
Your Name
“
and
press Enter. You’ll find every file on the hard drive that contains your name.
548592c10.indd 194
2/24/10 12:48:27 PM
www.finebook.ir
Understanding the Command Line
❘
195
In some cases, the administrator must work at the command line. If you’ve taken a look at Windows
Server 2008 Server Core edition, you know that it doesn’t include much in the way of a graphical
interface. In fact, this version of Windows immediately opens a command processor when you start
it. There’s no desktop, no icons, nothing that looks even remotely like a graphical interface. In fact,
many graphical applications simply don’t work in Server Core because it lacks the required DLLs.
When faced with this environment, you must know how to use command line applications.
You see the terms “application,” “utility,” and “command” used throughout this
chapter. An application can refer to any executable code. A utility is a specialized
kind of application that performs low-level tasks and includes automation sup-
port. Utilities aren’t part of the command processor (the application that provides
the command line interface) — they exist as separate files. A command is a utility
that resides within the command processor. For example, the
Dir
command is a
command because it exists as part of
CMD.EXE
; you won’t find a separate
Dir.EXE
residing somewhere on the hard drive.
Don’t get the idea that command line applications are a panacea for every application ailment or
every administrator need. Command line applications share some common issues that prompted
the development of graphical applications in the first place. Here are the issues you should consider
when creating a command line application of your own:
➤
Isn’t intuitive or easy to learn.
➤
Requires the user to learn arcane input arguments.
➤
➤
Relies on the user to open a separate command prompt.
➤
➤
Is error prone.
➤
➤
➤
➤
Output results can simply disappear when starting the application without opening a
separate command prompt.
Of course, you wouldn’t even be reading this chapter if command line applications didn’t also provide
some benefits. In fact, command line applications are the only answer for certain application needs.
Here are the benefits of using a command line application.
➤
Fast, no GUI to slow things down
➤
Efficient, single command versus multiple mouse clicks
➤
➤
Usable in automation, such as batch files
➤
➤
Less development time, no GUI code to write
➤
➤
Invisible when executed in the background
➤
➤
Command line applications can have other benefits. For example, a properly written, general
command line application can execute just fine on more than one platform. Even if you use
.NET-specific functionality, there’s a very good chance that you can use an alternative, such as
548592c10.indd 195
2/24/10 12:48:27 PM
www.finebook.ir
Do'stlaringiz bilan baham: |