Skip to content

Instantly share code, notes, and snippets.

@stevenklise
Created October 2, 2011 19:00
Show Gist options
  • Save stevenklise/1257779 to your computer and use it in GitHub Desktop.
Save stevenklise/1257779 to your computer and use it in GitHub Desktop.
A daemon to maintain a telnet session for a web client. Looks for Tasks that are not done, sends the command to the telnet client and then marks the Task as done.
while true do
t = Task.first(:done => false)
if t
if t.command == "connect"
@host = Net::Telnet.new({
"Host" => "128.122.151.161",
"Port" => 8080, "Timeout"=>25,
"Output_log"=>"output_log.log",
"Dump_log"=> "dump_log.log",
"Prompt"=> /C:.*>/
})
else
@host.puts(t.command)
end
t.done = true
t.save
end
end
class Task
include DataMapper::Resource
property :id, Serial
property :done, Boolean
property :command, String
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment