Database Reference
In-Depth Information
It is inadvisable to include the password on the command line because of the security implications of exposed
passwords. If the password is not included as a parameter, EM CLI will prompt the user for a password, and the characters
entered will not be echoed to the screen, nor will the password be exposed when looking at the running processes using
the ps command. If the -autologin parameter was not specified during setup, a login session will prompt for a password:
[oracle ~]$ emcli login -username=sysman
Enter password :
Login successful
In the case of running EM CLI in scripting or interactive mode, the login information must be explicitly given for
each script execution and at the beginning of each interactive session. These two modes do not use the credentials
established during setup, even if the -autologin parameter was used.
A simple script can be created to establish a connection and can be used in both interactive and scripting modes.
The login script needs to specify the URL by which to connect, the SSL authentication method, and a login credential.
Both of these modes expect a Python script (Listing 3-8).
Listing 3-8. Login script to be used in interactive and scripting modes
from emcli import *
set_client_property('EMCLI_OMS_URL', ' https://oem.example.com:7802/em ' )
set_client_property('EMCLI_TRUSTALL', 'true')
myLogin(username='sysman')
myLogin()
Placing this text in a file with an extension of .py makes it a module that can be imported into EM CLI. For example,
the script can be called login.py and placed in the /home/oracle/scripts directory. However, EM CLI will not
necessarily be able to find the script, because this path is not in the default Jython path. Explicitly defining the Jython
search path will guarantee that any scripts within that search path can be imported by EM CLI. The JYTHONPATH
variable can be supplemented with the additional directory:
export JYTHONPATH=$JYTHONPATH:/home/oracle/scripts
Similar to how the EM CLI Jython module was imported into the script with the command from emcli import * ,
the login script can be imported into either the interactive or scripting modes. To establish a login in interactive mode,
we can simply import the module. We will then be prompted to enter the password for the user specified in the script.
Listing 3-9 shows an example of using the login script in interactive mode.
Listing 3-9. Establishing a logon in interactive mode using the login module
[oracle ~]$ emcli
Oracle Enterprise Manager 12c EMCLI with Scripting option Version 12.1.0.3.0.
Copyright (c) 1996, 2013 Oracle Corporation and/or its affiliates. All rights reserved.
Type help() for help and exit() to get out.
emcli>import login
Enter password : *********
emcli>
 
Search WWH ::




Custom Search