Created
October 2, 2011 19:00
-
-
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.
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
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 |
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
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