2004.12_Put It in a Script.pdf

(2575 KB) Pobierz
Layout 1
Scripting Secrets Intro
COVER STORY
Putitin a Script
Not every expert computer user is a programmer, but if you want to be an expert, you’d better know something about
scripting -- especially if you’re working in Linux. BY JOE CASAD
has always ascribed to the philoso-
phy of using simple tools in
interesting ways. A script is a way of
automating commands, but, as you will
see in this issue of Linux Magazine, a
script is also a means of connecting
tools. Every command is a tiny tool, of
course, but some tools are especially
useful for scripters. Some tools, in fact,
are whole languages that fit comfortably
within other languages so that you can
build better and more efficient scripts. In
this issue you’ll see examples of grep and
AWK, for instance. You’ll also get some
tips on scripting with Bash, and you’ll
learn about advanced scripting tech-
niques for conditional statements and
command substitution.
Because all tasks, and all Linux users,
are not the same, a variety of scripting
languages are available, and we touch on
some of the most important languages in
this issue.
We start out with an odyssey into
scripting with Bash (the Bourne Again
Shell). Bash, the default shell on many
Linux systems, will be very familiar to
many readers. But we wanted to go
beyond what most users see. In our lead-
off article, “Gaining Control: Building a
Bash Web Admin Script,” by Peer Hein-
lein, we show you a script for
administering a web server in a real-life
production environment. And as you
will see, the best part of the article isn’t
the commands but the techniques -- the
tricks for getting to an efficient solution
through advanced knowledge of script-
ing tools and the web service
infrastructure.
Next in the set is an article on the
classic Unix scripting language AWK.
The article “Regular Wizardry: AWK
with a Text-file Table,” by Nico
Hochgeschwender, shows
AWK in action. AWK has
been around so long
that almost everyone
has heard of it,
but, with the
variety of newer
and more ver-
satile
languages
available, one
does not always
think of AWK as
a tool of choice
for very practical
problems on the
modern network. In
this case, we’ll show you
a practical case study that
demonstrates
how a system
administrator
could use AWK to
search a text-file table
that contains configura-
tion information on network
computers.
Rounding out our set of scripting
themes is an advanced look at Perl 6
from Linux Magazine,’s regular Perl
columnist Mike Schilli. If you loved Perl
5, you might like Perl 6 even more. We’ll
give you a look at what’s ahead in the
the world of Perl.
And if you’re looking for another arti-
cle in this month’s issue that may be
interesting reading for scripting special-
ists, try Heike Jurzik’s piece on the
ImageMagick toolset. The ImageMagick
tools, which let you manipulate graphic
images through text-based commands,
could lead to imteresting possibilities if
you like to experiment and you’re in the
mood for some scripting.
COVER STORY
Bash scripting ...................... 20
PutBash to work on your network. You can
use Bash to check up on your web server.
You’ll learn how Bash can help you with
checking your server’s status and hunting
for hidden root users.
AWK ........................................ 30
A practical look at using AWK to access and
manage a text-file table.
Perl 6 Preview ....................... 33
Linux Magazine Perl columnist Mike Schilli
takes an inside look at soon-to-be-release
Perl 6. Learn about what’s coming in the
brand new Perl.
www.linux-magazine.com December 2004
19
Techniques for scripting in Linux
L inux is a godchild of Unix, and Unix
564419653.001.png
Zgłoś jeśli naruszono regulamin