title: Save an output file on disk using shell commands in a django app
body: <p>I am creating a script to run shell commands for simulation purposes using a web app. I want to run a <code>shell</code> command in a <code>django</code> app and then save the output to a file. </p>
  
  <p>The problem I am facing is that when running the <code>shell</code> command, the output tries to get saved in the url that is invoked (for example: <code>localhost:8000/projects</code>) which is understandable. </p>
  
  <p>I want to save the output to for example:
  <code>/home/myoutput/output.txt</code> rather than <code>/projects</code> or <code>/tasks</code></p>
  
  <p>I have to run a whole script and save it's output to the txt file later but that is easy once this is done.</p>
  
  <p>Tried <code>os.chdir()</code> function to change directory to <code>/desiredpath</code> already</p>
  
  <pre class="lang-py prettyprint-override"><code>from subprocess import run
  
  #the function invoked from views.py
  def invoke_mpiexec():
    run('echo "this is a test file" &gt; fahadTest.txt')
  
  
  </code></pre>
  
  <blockquote>
    <p>FileNotFoundError at /projects</p>
    
    <p>Exception Type:   FileNotFoundError</p>
  </blockquote>