我正在尝试使用 python 在 linux 上运行 SAS 程序。此服务器已安装 SAS(版本 9.4)。我拥有的python版本是3.7.3。我了解到有一个可以使用的库 saspy,但是我的项目无权访问该库。所以,我找到了另一种选择,我的意图是在python中调用sas程序并在成功完成时获取返回码。这个 Sas 程序通常需要 1 小时才能完成。所以,我想在成功时使用返回码,然后想通过电子邮件通知自己。我编写了以下代码(示例),但无法使子流程正常工作?任何帮助表示赞赏。谢谢
#!usr/bin/python import os import subprocess import time **My function begins here** def Trigger_func(T): if T == 1: start = time.time() /** want to start a timer to know how long it takes to complete*/ #cmd = os.system('BGsas -p path/Sample.sas') /** SAS code is being invoked properly if used in this way */ sas_script = 'path/Sample.sas' /* Just a variable for the sas code path */ cmd2 = f'BGsas -p {sas_script}' result = subprocess.call(cmd2, shell=True) /* if I use this subprocess to call the sas code it is not working, I am getting the return code <> 0 **/ if result == 0: stop = time.time() - start return [1, stop] else: stop = time.time() - start return [0, stop] """""""" When the above process is completed, I will use this success return code to notify myself through an email """"""""""""