Database Reference
In-Depth Information
The Enterprise Manager Command-Line Interface is written almost entirely in Java and Jython. The download
of EM CLI from the OMS is a JAR file that requires the Java executable to install. When EM CLI is used in interactive
mode, the command-line interface is Jython.
The rest of this chapter will refer to Python and Jython interchangeably. This is because most users start out with
Python and subsequently learn Jython, or use only Python language (no Java) when using Jython. There is a great deal
of information and tutorials for Python on the Internet and in topics, so it is advised to search “Python” instead of
“Jython” when looking up syntax, examples, and so forth.
If you've ever used any of Oracle's middleware products, you have likely already come across Jython. WebLogic
Application Server's Scripting Tool (also known as “wlst”) also uses Jython.
JSON
The output of EM CLI commands will be displayed in one of two ways. The standard tabular or columnar format is
known as “text” mode. The text mode is generally the most readable form of the data up to a certain point. For example,
a table with five columns displays well in text mode, but a table made up of 20 columns is very difficult to read or parse.
Text mode is the default mode of display for EM CLI interactive mode.
An alternative to text mode for displaying command output is JavaScript Object Notation, commonly known as JSON. JSON
was originally derived from JavaScript and has since become a universal tool for data interchange. Nearly every programming
and scripting language not only uses and understands JSON, but also has a vast array of built-in functionality for it.
JSON is the default method of storing and displaying command output for the “scripting” mode of EM CLI, which
was built for processing EM CLI commands and output. It is expected that the data received from the commands
processed in an EM CLI script will be manipulated in some way.
Getting Started
Python was built for ease of use and brevity. For those reasons, it is not difficult for a novice to learn the basic
functionality of the language and to use it to accomplish tasks. DBAs often have an advantage when it comes to
learning Python because of their experience with PL/SQL, Java, shell scripting, various command-line interfaces, and
analytical tendencies.
Perhaps Python's most noticeable feature is the use of indentation for block structure. Instead of using open and
close statements to enclose a block of flow control, such as if statements, Python uses four spaces to indent lines of
code that belong to a block. Therefore, the line above the first line not indented ends the block. The first line of the
block is always followed by a colon.
>>> for VAR in myLoop:
... do this command
>>> this line does not belong in the loop
Both Python and Jython (as well as EM CLI and WLST) have an interactive interface in which any command
executed in a script can be written or copied and executed to see the results in real time. Most Linux hosts will have
Python installed. To invoke the interactive interface, simply type python :
[root@server ~]# which python
/usr/bin/python
[root@server ~]# python
Python 2.6.6 (r266:84292, Jul 10 2013, 06:42:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>print("this is the interactive Python prompt")
this is the interactive Python prompt
>>>exit()
 
Search WWH ::




Custom Search