1

I need to check GoldenGate processes' lag. In order to this, I execute Goldengate than I try to run GoldenGate's own commands "info all".

import subprocess as sub
import re
import os

location = str(sub.check_output(['ps -ef | grep mgr'], shell = True)).split()
pattern = re.compile(r'mgr\.prm$')
print(type(location))
for index in location:
        if pattern.search(index)!=None:
                gg_location = index[:-14] + "ggsci"

exec_ggate = sub.call(str(gg_location))
os.system('info all')

Yet, when I execute the GoldenGate it opens a new GoldenGate's own shell. So, I think because of that, Python cannot be able to do run "info all" command. How can I solve this problem? If there is missing information, please inform me.

Thank you in advance,

Umut TEKİN
  • 856
  • 1
  • 9
  • 19
  • the `call` is blocking. So `os.system` won't run until the call has ended. You mean to run the goldengate in background? – Jean-François Fabre Nov 29 '18 at 13:37
  • Yes, Goldengate runs in background, but I have to run "info all" command on GoldenGate's shell before it ends. – Umut TEKİN Nov 29 '18 at 13:39
  • aah you want to pass `info all` into process `stdin`, you need `Popen` probably, check this: https://stackoverflow.com/questions/163542/python-how-do-i-pass-a-string-into-subprocess-popen-using-the-stdin-argument – Jean-François Fabre Nov 29 '18 at 13:42
  • 1
    Try `pexpect` module: https://pexpect.readthedocs.io/en/stable/overview.html – reartnew Nov 29 '18 at 13:46

1 Answers1

1

For command automation on Golden Gate you have the following information in the Oracle docs: https://docs.oracle.com/goldengate/1212/gg-winux/GWUAD/wu_gettingstarted.htm#GWUAD1096

To input a script Use the following syntax from the command line of the operating system.

ggsci < input_file

Where: The angle bracket (<) character pipes the file into the GGSCI program. input_file is a text file, known as an OBEY file, containing the commands that you want to issue, in the order, they are to be issued.

Taking your script (keep into mind I don't know to code into python) you can simply execute a shell command in python in the following way:

import os
os.system("command")

So try doing this:

import os
os.system("ggsci < input_file")

Changing the input_file as indicated by the docs. I think you will have an easier time doing it this way.

Ivo Yordanov
  • 146
  • 1
  • 8