什么是win32api for Linux的替代品?

时间:2016-08-26 13:44:51

标签: ruby-on-rails ruby linux system

我有一个用于站点响应的Ruby代码。检查站点是UP还是Down。但它只适用于windows。如果我想将它用于Ubuntu会有什么变化?我试图运行这个但win32api线在Ubuntu上出错。

require "net/https"
require "uri"
require "Win32API"
uri = URI.parse("https://address ")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
test = response.body
delay = 10
message = "Site is OK"
title = "Up"
api = Win32API.new('user32', 'MessageBox',['L', 'P', 'P', 'L'],'I')
until !test.include? "false"
time = Time.now.strftime("%d/%m/%Y %H:%M")
puts time
puts "Down"
response = http.request(request)
test = response.body
sleep(delay)
end
api.call(0,message,title,0)
until test.include? "false"
api.call(0,message,title,0)
time = Time.now.strftime("%d/%m/%Y %H:%M")
puts time
puts "Up"
response = http.request(request)
test = response.body
sleep(delay)
end

0 个答案:

没有答案