[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

telnet terminal issue

Alex Ciarlillo

11/27/2006 3:40:00 PM

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:
<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

</code>

--
Posted via http://www.ruby-....

1 Answer

Paul Lutus

11/27/2006 6:39:00 PM

0

Alex Ciarlillo wrote:

> 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

The full Telnet protocol consists of hundreds of properties that the local
machine may or may not be able to support. If the local Telnet session
reports that it supports a property, such as the ability to clear the
screen, and then balks at a subsequent command to do so, the sort of
message you are getting is the result.

Perhaps the server requires the functionality that it is reporting on, and
cannot function at all without it. If that is the case, the specific site
you visited may not work out.

Many Telnet servers don't care about the more advanced features, but some
require them. The local Telnet client session may not be able to find out
whether the require property exists (because it cannot query the console
you are using), or it may not be forwarding it correctly, or some third
possibility.

--
Paul Lutus
http://www.ara...