Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require "rubygems"
- require "active_record"
- require "/home/totalip/ipserver/app/models/user"
- require "/home/totalip/ipserver/app/models/channel"
- require 'socket'
- ActiveRecord::Base.establish_connection({
- :adapter => "postgresql",
- :database => "totalipdb",
- :username => "totalip",
- :password => "",
- :host => "192.168.1.92"
- })
- require 'socket'
- @sock = TCPSocket.new('localhost',5038)
- login = "Action: Login\r\nUsername: admin\r\nSecret: nagioscheck\r\nEvents: On\r\n\r\n"
- @sock.write(login)
- res = select([@sock],nil,nil,0.3)
- if !res.nil?
- # Check to see if at EOF
- if @sock.eof?
- # Server closed the connection
- break
- end
- data = @sock.gets
- event = ""
- while data != "\r\n"
- event << data
- data = @sock.gets
- end
- puts event
- event.split("\r\n")
- puts event[0]
- end
- Returns:
- Asterisk Call Manager/1.0
- Response: Success
- Message: Authentication accepted
- 65
Add Comment
Please, Sign In to add comment