title: python sub-process
body: <p>I usually execute a Fortran file in Linux (manually) as:</p>
  
  <ol>
  <li>Connect to the server</li>
  <li>Go to the specific folder</li>
  <li><code>ifort xxx.for -o xxx &amp;&amp; ./xxx</code> (where 'xxx.for' is my Fortran file and 'xxx' is Fortran executable file)</li>
  </ol>
  
  <p>But I need to call my fortran file (xxx.for) from python (I'm a beginner), so I used <code>subprocess</code> with the following command:</p>
  
  <pre><code>cmd = ["ssh", sshConnect, "cd %s;"%(workDir), Fortrancmd %s jobname "%s -o  %s" exeFilename "%s &amp;&amp; %s ./ %s%s"%(exeFilename)]
  </code></pre>
  
  <p>But I get an error, and I'm not sure what's wrong. Here's the full code:</p>
  
  <pre><code>import string
  import subprocess as subProc
  from subprocess import Popen as ProcOpen
  from subprocess import PIPE
  import numpy
  import subprocess
  
  userID = "pear"
  serverName = "say4"
  workDir = "/home/pear/2/W/fortran/"
  Fortrancmd = "ifort"
  jobname = "rad.for"
  exeFilename = "rad"
  
  sshConnect=userID+"@"+servername
  
  cmd=["ssh", sshConnect, "cd %s;"%(workDir), Fortrancmd %s jobname "%s -o  %s" exeFilename "%s &amp;&amp; %s ./ %s%s"%(exeFilename)]
  
  **#command to execute fortran files in Linux
  **#ifort &lt;filename&gt;.for -o &lt;filename&gt; &amp;&amp; ./&lt;filename&gt; (press enter)
  
  **#example:ifort xxx.for -o xxx &amp;&amp; ./xxx (press enter)
  
  print cmd
  </code></pre>
  
  <p>How can I write a python program that performs all 3 steps described above and avoids the error I'm getting?</p>