title: Using Subprocess with Python
body: <p>I am creating a Django application that takes an input file from a user. I want to use the subprocess module to take the file and pass it as an argument to an external script and take back the results. What would be the format for the subprocess.Popen call. I would like, to also pass an option to the script like -a.
  In other words how would a subprocess.Popen call look like for a command line that looks something like this:</p>
  
  <pre><code>./myscript -option file
  </code></pre>
  
  <p>Also are there any issues regarding the path of the script i am trying to run. Thanks a lot.</p>
  
  <p>This is the code that I am using in my views.py. I am just trying to see if a simple cp command works and how to pass the arguments:</p>
  
  <pre><code>def upload_file(request):
  
      if request.method == 'POST':
      form=UploadFileForm()        
      form = UploadFileForm(request.POST, request.FILES)
          if form.is_valid():
              handle_uploaded_file(request.FILES['file'])
              return HttpResponseRedirect('/upload')
      else:
          form = UploadFileForm()
      return render_to_response('upload_file.html', {'form': form})
  
  def handle_uploaded_file(f):
  
      p=subprocess.Popen(['/bin/cp',f , '/home/dutzy/Desktop'])
  </code></pre>