12.07.2015 Views

Red Hat Enterprise Linux 5 Administration Unleashed

Red Hat Enterprise Linux 5 Administration Unleashed

Red Hat Enterprise Linux 5 Administration Unleashed

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Additional Scripting Languages 247The asterisk can be used as a wildcard when defining the list. For example, *.html can beused to iterate through all the HTML files in the current directory.Additional Scripting LanguagesWhen automating system administration tasks, scripting languages such as Bash are mostcommonly used because they are efficient at executing a series of commands. However,other languages, both scripting and compiled, offer functions such as finding phrases intext files and replacing them with a different word or phrase, which can be helpful whenyou want to customize configuration files.11This section gives a brief overview of a few of the other scripting languages used in <strong>Red</strong><strong>Hat</strong> <strong>Enterprise</strong> <strong>Linux</strong> along with some of their advantages and disadvantages for systemadministrators.Writing Scripts with PythonCompared to Bash scripting, the syntax and features of Python look and feel more like areal programming language. Because the code is interpreted, not compiled into byte code,it can be used as a scripting language similar to Bash and can run on multiple platformsincluding <strong>Linux</strong>, Mac OS X, and the Microsoft Windows variants. Or, the programmer canchoose to utilize the object-oriented nature of Python and write more complex user-endapplications complete with graphical interfaces. In fact, all of the system-config-*configuration tools from <strong>Red</strong> <strong>Hat</strong> are written in Python.One of Python’s strengths is its easy-to-read syntax. Instead of having to use semicolonsand remembering what keyword is used to end a loop, the programmer simply uses consistentindentation to tell the interpreter what lines are part of which functions or loops.The python RPM package needs to be installed to use Python. If you don’t have itinstalled, refer to Chapter 3, “Operating System Updates,” for instructions. There are alsopackages that provide additional Python modules such as rpm-python for developingPython programs to interface with the RPM packages or database. Install these additionalpackages if you require their functionality.Documentation for Python can be found at http://python.org/doc/, by installing thepython-docs RPM package, and in books dedicated to teaching Python.Writing Scripts with PerlSimilar to Python, Perl is available for many different operating systems, so its code canbe easily ported to multiple operating systems. Perl’s strengths include its process, file,and text-manipulation abilities. It is commonly used to write system managementprograms, scripts to access databases, and CGI scripts for the web. For example, thelogwatch utility discussed in Chapter 20, “Monitoring System Resources,” includes Perlscripts to generate log file reports.The perl RPM package needs to be installed to use Perl. Optionally, packages that includeadditional Perl modules can be installed such as perl-DBI for accessing databases withPerl and perl-HTML-Parser for parsing HTML files in Perl.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!