Last active
March 23, 2017 08:07
-
-
Save KarambaKG/bee0adbe54df981c4183d13a5ff99ea1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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