Why is 'curl' not recognized when running in Windows? - ruby

I am trying to run a Curl command wrapped inside Ruby code as below:
f=IO.popen("C:\Windows\System32\curl.exe -H 'Authorization: Bearer #{token}' -s -v -D - http://api.pageuppeople.com/v1/NAS/Config/LanguageDictionary/Overrides --debug 2>NUL").readlines
However, the output I get is:
'curl' is not recognized as an internal or external command, operable program or batch file
I am running on Windows 7.
I also have "C:\Windows\System32" set in the environment path.
Please help.

curl is not a component of Windows. Unless you have specifically installed it, it won't exist on the system.
I am not a Ruby expert, but I suspect that you should really be using the Net::HTTP Ruby library here, or something similar to it. Even on a system where curl is installed, launching it is not a sensible way of running an HTTP request.

Curl does not come with Windows, but it has been ported to Windows.
You can download it here:
http://sourceforge.net/projects/gnuwin32/file
I know nothing about Ruby, but I do know you shuld be using a native libary for your HTTP needs.

CURL is not a Windows component. Download curl.exe and keep it in your path.
Alternatively download curl.exe and invoke the command from the same folder.

Windows 10 now provides C:\Windows\System32\curl.exe but I still see that error message when I try to call it from a service (Jenkins user in my case).
I'll post an update when I find out something more (e.g. which user rights are necessary).
I've installed curl now with chocolatey. See https://chocolatey.org/packages/curl.

Related

curl hangs while uploading on Windows

I am using curl on mac and other windows machines to upload my artifacts to HockeyApp service. On one of my machines that runs windows , "curl" constantly "hangs/freezes" during upload.
Here is the command :
curl -F notify=0 -F status=2 -F ipa=#app/build/outputs/apk/app-production-release-2.4.2-SNAPSHOTv42.apk -F dsym=#app/build/outputs/mapping/production/release/mapping.txt -H X-HockeyAppToken:[MY_TOKEN_HERE]https://rink.hockeyapp.net/api/2/apps/[MY_APP_REFERENCE]/app_versions/upload
On windows there is no curl by default , so I use the one installed with this git distribution. I just add the path to curl to path environmental variable. This approach works well on 2 other windows machines. In fact when I open git-bash , the curl command also executes fine. But any attempt to run it from cmd.exe leads to "hanging/freezing".
Any idea on how can I troubleshoot/debug it ?
EDIT :
I have already tried other curl distributions for windows , same result...
I've been struggling with the same issue of curl as well when trying to deploy my app from VSTS to Hockeyapp. in the end I've chosen for not using curl but just using plain powershell on Windows. it's a bit more complicated but it works the same way.
I've uploaded this script to GitHub and can be found there:
https://github.com/Geertvdc/UWPHockeyAppDeployScripts/blob/master/UploadUWPToHockeyApp.ps1
so instead of curl I use Invoke-RestMethod from powershell to do the same call to Hockeyapp.
Try to upgrade your curl to the latest version
where curl
find out where current path of curl, using cywin cli
https://curl.haxx.se/windows/
Come here to find version you want update, download and give it a try.
Reason for this freezing is base on Windows config. I have laptop that need to ghost new installation of Windows 10. Before ghost, curl run well. After ghost, sometime it freezing.
I updated and it runs well now.
Also notice that when run
curl -s
curl will run in silent mode, that never hang out

How do I create a new proxy in Windows?

I am trying to setup BrowserMobProxy and the instructions in the README found here: https://github.com/lightbody/browsermob-proxy say to run the batch file, which I have and then to do the following to create a new proxy, using the following command:
[~]$ curl -X POST http://localhost:9090/proxy
{"port":9091}
How do I do this in Windows?
I followed the instructions here: http://rdekleijn.nl/functional-testing-over-a-proxy-with-browsermob-proxy/
The only thing that I would change is that when I wanted to get the curl command to work that I had to point it to c:\Program Files\cURL\bin and then run the curl command. It did work though.

Node.js install module on windows

Cmd error: "sh" is not recognized as an internal or external command, operable program or batch file.
C:\Users\user>npm install -g node-curl
npm http GET https://registry.npmjs.org/node-curl
npm http 304 https://registry.npmjs.org/node-curl
> node-curl#0.1.4 install C:\Users\user\AppData\Roaming\npm\node_modules\node-cu
rl
> sh src/generate_curl_options_list.sh && node-waf configure build || true
"sh" is not recognized as an internal or external command, operable program or batch file.
"true" is not recognized as an internal or external command, operable program or batch file.
To expand on Florian's answer: You're on Windows, which doesn't have cURL or sh. You're trying to install a module that relies on your operating system offering the libcurl-library and sh, which is not shipped with Windows.
You have some options:
Write your own node-only implementation that behaves like curl.
See this question on SO: Curl equivalent in nodejs?
It goes into details of how to use the built-in http module, like curl.
Or install libcurl and sh on windows, with a tool like cygwin. I haven't tried this, and the npm module you're trying to install might still have dependencies on other unix tools that aren't solved by cygwin.
Or look for something else in http://search.npmjs.org/ that behaves like curl. Try httpsync or curly
I recommend option 1, it'll teach you basic http principles. The native modules in node already offer everything you might need curl for. :)
Well, using node-curl on windows, that doesn't have curl, is quite stupid.
Don't try.

Curl command not loading contents in windows 7

I have installed Cygwin & curl(through cygwin installer) on my Windows7 32bit. Then opened cygwin terminal and typed curl --help. Everything works fine with curl showing its command arguments list.
But curl http://www.google.com or any other url takes more time and results
"curl: (52) Empty reply from server
". What is the problem?
Update:Iam behind a proxy server. Any pblm with that?
If your proxy server is the only way to get out at the web, then yes, that's the problem. Curl couldn't care less about what OS you're running under, so won't get for OS-specific proxy settings (ie: Internet Explorer options), so it'll try to do a direct connection. Try adding the --proxy option (curl --help will give the format).

Using Curl to get a Https webpage in Windows 7

I just need to fetch an https page, and I'm using curl currently by having the curl.exe application in my Path and calling it with a Perl file. However, then I get the error "* Protocol https not supported or disabled in libcurl". I've been looking around and I can't find a solid set of instructions to get it to work. I have installed cygwin, and OpenSSL-Win32 but something tells me I'm going to have to compile curl from scratch. I have no experience with this. How do you do it?
I found the below steps worked well
Download and unzip 64-bit cURL with SSL.
Download the latest bundle of Certficate Authority Public Keys from mozilla.org.
Rename this file from cacert.pem to curl-ca-bundle.crt
Make sure both of them are in the PATH environment.
Test
curl -L https://www.google.com
UPDATE
If you are open to try other tools, I think httpie is also a good alternative.
curl --insecure
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.

Resources