后台使用gateway来运行命令是不会跳红窗报警的,看了下奥宝的文档,似乎本意就是不会弹窗报警。
但是可以用gateway <pid+host> "ERR <errcode>"来获得返回的代码对应的英文解释
Python代码如下:
def run_script(self, path, pid, para1, para2):
gateway_para = '%' + str(pid) + '@' + str(MyCmd.hostname) + '.' + str(MyCmd.hostname)
com_str = '\"COM script_run,name={_name},env1=JOB={_job},env2=STEP={_step}\"'.format(_name = path, _job = para1, _step = para2)
cmd = MyCmd.gateway + ' ' + gateway_para + ' ' + com_str
res = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
out, err = res.communicate()
res_flag = str(out.splitlines()[0], encoding = "utf8")
if int(res_flag) != 0: # 有错误代码则再用gateway翻译代码
com_str = '\"ERR {_code}\"'.format(_code = res_flag