Skip to content

Instantly share code, notes, and snippets.

@KarambaKG
Last active March 23, 2017 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KarambaKG/bee0adbe54df981c4183d13a5ff99ea1 to your computer and use it in GitHub Desktop.
Save KarambaKG/bee0adbe54df981c4183d13a5ff99ea1 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'json'
require 'byebug'
require 'pry'
def create_agent
all_params = Hash.new
ARGV.each {|arg| c=arg.split('='); all_params[c[0]]=c[1] }
remote_host = all_params['ip']
uri = URI("http://#{remote_host}:9292/new")
http = Net::HTTP.new(uri.host, uri.port)
req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/json')
req.body = all_params.to_json
res = http.request(req)
if res.kind_of? Net::HTTPSuccess
p 'JSON параметры успешно отправлены'
p res
else
p 'ups! Что то пошло не так('
p res
end
end
create_agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment