I am trying to invoke a sas script using python and subprocess. This is my code:
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]
I am not including the autoexec_path for SAS,because I did not find any autoexec file. if I have the autoexec file then,
self.cmd = [sas_path,'-config',sas_config_path,'-autoexec',autoexec_path,'-sysin',sas_code_path]
The problem is the SAS code executes successfully, but proc.returncode is not equal to 0. Therefore, my python code doesn't know that the code ran successfully.
Is there anything that I am doing wrong?
