title: curl command from commandline runs fine but from python subprocess I get an error
body: <p>If I run the below command using curl, its a success:</p>
  
  <pre><code>curl -XPOST 'localhost:9260/icrd_client_1' -d @clientmappings.json
  </code></pre>
  
  <p>This command creates an index in elasticsearch based on json file. I get a pleasant output: </p>
  
  <pre><code>{"ok":true,"acknowledged":true}
  </code></pre>
  
  <p>The issue I am experiencing is when running this command from a python script. </p>
  
  <p>Instead of the pleasant output above after executing my script, I get the following output:</p>
  
  <pre><code>['curl', 'XPOST', 'http://localhost:9260/icrd_client_1 -d @clientmappings.json']
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  curl: (52) Empty reply from server
  Traceback (most recent call last):
    File "./elastic_ops.py", line 57, in &lt;module&gt;
      output = run_curl(command, composed_url)
    File "./elastic_ops.py", line 36, in run_curl
      return subprocess.check_output(cmd)
    File "/usr/lib/python2.7/subprocess.py", line 544, in check_output
      raise CalledProcessError(retcode, cmd, output=output)
  subprocess.CalledProcessError: Command '['curl', 'XPOST', 'http://localhost:9260/icrd_client_1 -d @clientmappings.json']' returned non-zero exit status 52
  </code></pre>
  
  <p>The output is not a oneliner json response as I got from the real curl command from the cmdline. 
  I have 2 Quesions: </p>
  
  <p>1) How can I capture the real lovely output command: <code>{"ok":true,"acknowledged":true}</code> instead of the jiberish about the network packets transfered etc.</p>
  
  <p>2) What command needs to be sent to the <code>subprocess</code> for this to work like a normal cmdline curl command. </p>
  
  <p>I call the python script like this:</p>
  
  <pre><code>./elastic_ops.py create icrd_client_1 http://localhost:9260 clientmappings.json
  </code></pre>
  
  <p>And here is the relevant code of my python script:</p>
  
  <pre><code>commandline_args = sys.argv
  
  command_type = commandline_args[1]
  index_name = commandline_args[2]
  base_elasticsearch_url = commandline_args[3]
  file_to_index = sys.argv[4] if len(sys.argv) &gt; 4 else None
  
  def run_curl(command, url):
      cmd = ['curl', command, url]
      print 'sending command: '
      print cmd
      return subprocess.check_output(cmd)
  
  # create Index
  # curl -XPOST 'localhost:9260/icrd_client_1' -d @clientmappings.json
  if (command_type == 'create'):
      print 'About to run '+command_type+' for Index: '+index_name+' from filename: '+file_to_index
      command = 'XPOST'
      composed_url = base_elasticsearch_url + '/' + index_name +' -d ' + '@'+file_to_index
      print 'URL Request Being sent is:'
      print '.... '+ composed_url
      output = run_curl(command, composed_url)
      print 'output:'
      print output
  </code></pre>