title: Running Terminal within a Python Script
body: <p>I am attempting to run a command in terminal through a Python script. The command, which only takes three arguments, works perfectly when performed in terminal. Here is what is entered in the command line:</p>
  
  <pre><code>gpmetis inputfile numberOfSections
  </code></pre>
  
  <p>Wherever the <code>inputfile</code> is from, say the Desktop, the <code>outputfile</code> is dumped in the same location after <code>gpmetis</code> is executed (it is named <code>inputfile.part.numberOfSections</code>). <code>gpmetis</code> only works in terminal, but for condensing purposes, I want to use it during the middle of the Python script to save time. (I would previously just shuffle around files to and from terminal and Python)</p>
  
  <p>But this is where I run into problems... this <a href="https://stackoverflow.com/questions/7574841/open-a-terminal-from-python">question</a> and this <a href="http://ubuntuforums.org/showthread.php?t=729192" rel="nofollow noreferrer">forum</a> gave helpful hints on how to execute terminal within Python, but I'm still not receiving the <code>outputfile</code> when I run the python code. It's like the output is suppressed or the way I call terminal is faulty. </p>
  
  <p>I'm currently calling terminal like:</p>
  
  <pre><code>def Terminal(inputfile, NumParts): 
      os.system("gpmetis inputfile NumParts")
  
      outputfile = "inputfile.part." + NumParts
      return outputfile
  </code></pre>
  
  <p>And I don't get an error from this, but I don't receive any output file either. What am I missing here and if you know could you explain it? I'm trying to learn Python, so describing what I'm screwing up would be much appreciated.</p>
  
  <p><code>os</code> has been imported. There may be a fault with how I am "returning" the <code>outputfile</code> in my script, but I also do not see an <code>outputfile</code> on my desktop, which is the first problem to be dealt with (one step at a time!)</p>
  
  <p>NOTE: I found <a href="http://docs.python.org/library/subprocess.html" rel="nofollow noreferrer">documentation</a> that is related, but will it help me? I'm having trouble understanding it..</p>