由于执行新的应用程序,Python OS命令不起作用

时间:2018-11-29 13:33:10

标签: python regex linux bash oracle-golden-gate

我需要检查GoldenGate进程的延迟。为此,我执行Goldengate比尝试运行GoldenGate自己的命令“ 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')

但是,当我执行GoldenGate时,它将打开一个新的GoldenGate自己的外壳。因此,我认为正因如此,Python无法执行“ info all”命令。我怎么解决这个问题?如果缺少信息,请通知我。

先谢谢您

1 个答案:

答案 0 :(得分:0)

对于Golden Gate上的命令自动化,您在Oracle文档中具有以下信息:true.png

输入脚本 从操作系统的命令行使用以下语法。

ggsci < input_file

其中:     尖括号(<)字符将文件传送到GGSCI程序中。     input_file是一个文本文件,称为OBEY文件,其中包含要发布的命令,这些命令将按顺序发出。

有了脚本(记住,我不知道要编写成python的代码),您可以通过以下方式在python中简单地执行shell命令:

import os
os.system("command")

所以尝试这样做:

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

按文档指示更改输入文件。 我想您这样做会更轻松。