由于执行了新的应用程序,Python OS命令无法工作

2024-10-03 06:30:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要检查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”命令。我怎样才能解决这个问题?如果有信息缺失,请通知我。你知道吗

先谢谢你


Tags: import命令reinfoindex进程oslocation
1条回答
网友
1楼 · 发布于 2024-10-03 06:30:45

对于金门上的命令自动化,您在Oracle文档中有以下信息:https://docs.oracle.com/goldengate/1212/gg-winux/GWUAD/wu_gettingstarted.htm#GWUAD1096

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

ggsci < input_file

其中: 尖括号(<;)字符将文件导入GGSCI程序。 input\文件是一个文本文件,称为OBEY文件,它包含您要发出的命令,这些命令按发出的顺序排列。

考虑到您的脚本(请记住,我不知道如何将代码转换为python),您只需按以下方式在python中执行shell命令:

import os
os.system("command")

所以试着这样做:

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

如文档所示更改输入文件。 我想你这样做会容易些。你知道吗

相关问题 更多 >