Database Reference
In-Depth Information
Chapter 5
Automation Through Shell Scripts
As we discovered in the previous chapter, EM CLI provides faster means of accomplishing complicated tasks that are
ordinarily managed through the OEM console. The strength of EM CLI is leveraged by combining EM CLI with classic
shell-scripting techniques. The examples in this chapter are written for use in a Unix/Linux environment but, because
EM CLI is a Java application, the CLI syntax shown here will work just as well in other environments.
This chapter begins with CLI scripting fundamentals and then works through several examples demonstrating
application of the technique. In each example, we've removed the common housekeeping commands that make
scripts robust in order to ensure our illustrations are clear. Since those techniques apply to any scripted solution,
we'll lay out some fundamental scripting guidelines before tackling any OEM solutions.
All the examples in this chapter are written using fundamental bash shell scripts due to their ubiquity and clarity.
Perl or other languages can be applied to improve script performance, but adding that element to this chapter could
mask the basics of the techniques being demonstrated.
This chapter begins by laying out some shell-scripting fundamentals and advances to building and applying shell
functions. Along the way we'll take a look at how to create and control OEM blackouts, manage user accounts, and
work with larger data sets. Finally, we'll take a look at some advanced shell-scripting techniques using getopts .
Best Practices for Shell Scripting
Everyone with experience in shell scripting, whether for Windows, Linux, or any other Unix variant, has their own
preferred techniques. Hopefully, the scripts in your environment present a consistent look and feel that makes it easy
to read and easy to maintain. Best practices for writing any program, regardless of shell or operating system, were laid
out by the creators of Unix and documented in The Art of Unix Programming by Eric S. Raymond. Those guidelines
provide a very clear foundation for any programming we perform. A free online copy of the topic is available at
https://archive.org/details/ost-computer-science-the_art_of_unix_programming .
Logging
Mysteries belong on your night stand and not in your Enterprise Manager environment. Output for any Unix program
should provide useful, complete, and concise screen output at run-time along with thorough log files. Log files are
created through the redirection of the shell output.
 
Search WWH ::




Custom Search