我正在尝试使用python和subprocess调用sas脚本。这是我的密码:
proc = Popen(self.cmd, shell=True, stdout=PIPE, stderr=STDOUT)
proc.wait()
standard_output, standard_error = proc.communicate()
if proc.returncode == 0:
log.info("Successfully executed execute_shell_command")
elif proc.returncode == 1:
self.status_message = "return code 1 from" + " ".join(self.cmd) + "error msg: " + str(standard_error)
self.flag = 1
raise ValueError(self.status_message)
elif proc.returncode > 1:
self.status_message = "Error occurred while executing command on shell :" + " ".join(self.cmd) + ' ' + standard_error
self.flag = 1
raise ValueError(self.status_message)
self.cmd = [sas_path,'-config',sas_config_path,'-sysin',sas_code_path]
我没有包括SAS的autoexec\u路径,因为我没有找到任何autoexec文件。 如果我有autoexec文件
self.cmd = [sas_path,'-config',sas_config_path,'-autoexec',autoexec_path,'-sysin',sas_code_path]
问题是SAS代码执行成功,但是proc.returncode
不等于0。因此,我的python代码不知道代码是否成功运行。
我做错什么了吗?你知道吗
日志中可能有警告。你知道吗
从文档中,"SAS® 9.4 Companion for Windows, Fifth Edition"
相关问题 更多 >
编程相关推荐