Forum Stats

  • 3,768,724 Users
  • 2,252,841 Discussions
  • 7,874,696 Comments

Discussions

calling sql statement in emcli using python script

3163453
3163453 Member Posts: 8
edited Jan 31, 2017 12:56AM in Python

Hi,

I am writing a code to fetch few details of the jobs using python script using emcli in interactive mode.

When i give the following code outside emcli, it works perfectly

D:\OMS_HOME>emcli list -sql="select sysdate-1 from dual"

SYSDATE-1

2017-01-26 06:07:34.0

Rows:1

But when I go with interactive mode, I see the session are getting disconnected.

Can anyone help to get the results out of it using interactive mode in emcli.

FYI , I am not able to use cx_oracle as I am using emcli @script1.py to execute the script

emcli>list (sql="select sysdate-1 from dual")

Error: Session expired. Run emcli login to establish a session.

emcli>list (sql='select sysdate-1 from dual')

Error: Session expired. Run emcli login to establish a session.

emcli>f_sql="select sysdate-1 from dual"

emcli>list (sql=f_sql)

Error: Session expired. Run emcli login to establish a session.

Answers

  • Gaz in Oz
    Gaz in Oz Member Posts: 3,784 Bronze Crown
    edited Jan 31, 2017 12:23AM

    Start by posting the output from:

    $ emcli status

    What does "script1.py" contain?

    What were the commands you used to install/setup emcli?

    What OS and version are you using?

    Cheers,

    Gaz.

  • 3163453
    3163453 Member Posts: 8
    edited Jan 31, 2017 12:32AM

    Hi Gaz,

    Thanks for your response.  I used emcli @script1.py for just to tell that I am using the python script using emcli.

    Os - windows  , EM CLI Version         : 12.1.0.4.0

    Due to security issues, I am not able to provide emcli status output.  Install/setup was done as per oracle doc.

  • Gaz in Oz
    Gaz in Oz Member Posts: 3,784 Bronze Crown
    edited Jan 31, 2017 12:56AM

    No problem.

    ...did you use the fully qualified domain name (FQDN) in your setup? (that would have also been listed out in emcli status)

    for example is the o/p from emcli status like this

    EM URL           : https://machinename.domain.com:7802/em

    or this

    EM URL           : https://machinename:7802/em

    ...and which Oracle doc? There are quite a few out there...

    ...and is this a client install, connecting to the EM server that is elsewhere?

    It is very difficult to help without knowing your setup.

This discussion has been closed.