Okay I am playing around with ruby and its telnet functionality and I
ran into an interesting problem. I am trying to pull up a report from a
telnet based program via ruby and I can navigate all the menus and enter
the date and times for the report I want but as soon as it would usually
pull up the report to the screen I receive this:
WARNING: terminal cannot clear to end of line
WARNING: terminal cannot clear screen
WARNING: terminal cannot home cursor
WARNING: terminal cannot move cursor to lower left of screen
WARNING: terminal cannot scroll backwards
I was just wondering if anyone here familiar with telnet shells might
understand what I am seeing. I am wondering if it might be how ruby
negotiates options with the server but I tried looking through Ethereal
and it all generally looks the same as if I were to connect using Putty.
Any ideas?
thanks
Here is the full code:
require ‘net/telnet’
#connect & login
optim = Net::Telnet::new(“Host” => “xxx.xxx.xxx.xxx”,
“Port” => 23,
“Timeout” => 60,
“Prompt” => /[?25h/,
“Output_log” => “out_log.txt”,
“Dump_log” => “dump_log.rtf”)
optim.login(“username”, “pass”)
puts “Connection Established.”
logFile = File.open(“C:\opt_test.log”, “w”)
#navigate to report screen (menu items 1,5,1)
sleep(1)
optim.cmd(‘1’) { |rcv| puts rcv } #reports
optim.cmd(‘5’) { |rcv| puts rcv } #sales
optim.cmd(‘1’) { |rcv| puts rcv } #location activity
puts “Please enter the date of interest in MM/DD/YYYY:”
date = gets.strip
puts “Please enter the meal period (breakfast, lunch, dinner):”
period = gets.strip
case period
when “breakfast”
sTime = “”
eTime = “11:00:a”
when “lunch”
sTime = “11:01:a”
eTime = “4:00:p”
when “dinner”
sTime = “4:01:p”
eTime = “”
else
puts “Uknown meal period: #{period}”
exit
end
#enter info
optim.puts(date.to_s)
optim.puts(sTime.to_s)
optim.puts(date.to_s)
optim.puts(eTime.to_s)
optim.write("\033OB\r") #down arrow for Location-Select
#enter locations for report
optim.puts(“843”)
optim.puts(“850”)
optim.puts(“823”)
optim.write("\033OP\r") #exit location entry
optim.puts("")
optim.puts("")
optim.puts("")
#wait for “performing request”
optim.waitfor(“Location:”) { |r| logFile.puts r
puts r
}
#scroll report and write to file
optim.waitfor("(END)") { |r| logFile.puts r
puts r
optim.cmd(‘d’)
}
optim.close
outFile.close