What is the correct Ruby syntax for making a curl system call?

To upgrade Redmine, I need SVN to test our Redmine installation from our post-commit hook. Our post-commit hook is a Ruby script that generates an email. I would like to insert a call:

curl --insecure https://redmineserver+webappkey

This call works from the command line, but when I try to do this:

 #!/usr/bin/ruby -w REFRESH_DRADIS_URL = "https://redmineserver+webappkey" system("/usr/bin/curl", "--insecure", "#{REFRESH_DRADIS_URL}") 

This does not work. How to do it in ruby? I googled a “ruby curl system”, but I have a bunch of links to integrate curl into ruby ​​(which is NOT what interests me).

+7
ruby curl
source share
4 answers

For such a simple task, I would not do with curl , I just did

 require 'net/https' http = Net::HTTP.new('redmineserver+webappkey', 443) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.get('/') 

And for more complex issues, I still don't lay out curl , but rather use one of the many Ruby libcurl bindings.

+4
source share

There are many ways

 REFRESH_DRADIS_URL = "https://redmineserver+webappkey" result = `/usr/bin/curl --insecure #{REFRESH_DRADIS_URL}` 

but I don’t think you should use curl. try it

 require 'open-uri' open(REFRESH_DRADIS_URL) 

If the certificate is not valid, it becomes a little harder

 require 'net/https' http = Net::HTTP.new("amazon.com", 443) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE resp, data = http.get("/") 
+7
source share
 system ("curl --insecure #{url}") 
+6
source share

I had to do this recently and tried the following and it worked:

test.rb

 class CurlTest def initialize() end def dumpCurl test = `curl -v https://google.com 2>&1` puts test end end curlTest = CurlTest.new() curlTest.dumpCurl 
0
source share

All Articles