3 Replies - 859 Views - Last Post: 26 June 2013 - 01:01 PM Rate Topic: -----

#1 NoRemorse  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 26-January 11

Curl is not recognized , using Popen()

Posted 26 June 2013 - 03:13 AM

p = Popen(["curl", "http://localhost:8983/solr/update/json?commit=true", "--data-binary", "@solrData.json", "-H", "Content-type:application/json"], cwd=r"C:/Users/SOLR/docs", shell=True)



Now I get curl is not recognized as an internal or external command error.
Any ideas?

Just as a comparison, this works perfectly:

p = Popen("java -jar post.jar solrData.xml", cwd=r"C:/Users/SOLR/docs")



and also when I am in the dir:C:/Users/SOLR/docs and run the command :

 curl "http://localhost:8983/solr/update/json?commit=true" --data-binary @solrData.json -H "Content-type:application/json"

everything works

This post has been edited by NoRemorse: 26 June 2013 - 03:40 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Curl is not recognized , using Popen()

#2 woooee  Icon User is offline

  • D.I.C Head

Reputation: 21
  • View blog
  • Posts: 78
  • Joined: 21-November 12

Re: Curl is not recognized , using Popen()

Posted 26 June 2013 - 12:49 PM

For starters, make sure it can find curl by providing a complete path
"/complete/path/curl"
You might also want to consider subprocess.call and pass the arguments as a list of strings

This post has been edited by woooee: 26 June 2013 - 12:49 PM

Was This Post Helpful? 0
  • +
  • -

#3 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7576
  • View blog
  • Posts: 12,733
  • Joined: 19-March 11

Re: Curl is not recognized , using Popen()

Posted 26 June 2013 - 12:56 PM

If you're asking about how to retrieve a file using python, I generally use urllib2 for this sort of thing. http://docs.python.o...ry/urllib2.html

Some people seem to like Requests. I haven't tried it myself, but here's a link if you want to check it out.

http://docs.python-r...test/index.html


If the question is about why you're having trouble calling curl from within python using os.popen - just use the wrappers, that's what they're for.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6039
  • View blog
  • Posts: 23,436
  • Joined: 23-August 08

Re: Curl is not recognized , using Popen()

Posted 26 June 2013 - 01:01 PM

If you're fixated on curl, try providing the full path to curl in the popen call.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1