title: How to utilize subprocess when invoking sas code in python on Linux server
body: <p>I am trying to run a SAS program on linux using python. This server has SAS installed (version 9.4). And python version I have is 3.7.3.</p>
  <p>I learned there is a library saspy which I could use however my project does not have access to this library. So, I found another alternative, my intension is to invoke the sas program in python and get the return code when it is successfully completed. This Sas program usually takes 1hr to complete.</p>
  <p>So, I would like to use the return code when it is successful and later would like to notify myself through an email. I wrote the below code (sample) and I unable to make the subprocess work ? Any help is appreciated. Thanks</p>
  <pre><code>#!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 &lt;&gt; 0 **/
         if result == 0: 
               stop = time.time() - start
               return [1, stop]
         else:
              stop = time.time() - start 
              return [0, stop]
  
  
     &quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot; 
     When the above process is completed, I will use this success return code to notify myself through 
     an email
     &quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;
  
      
  </code></pre>