telnet terminal issue

Discussion in 'Ruby' started by Alex Ciarlillo, Nov 27, 2006.

  1. 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-forum.com/.
    Alex Ciarlillo, Nov 27, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lucas Tam
    Replies:
    1
    Views:
    609
    Bennett Haselton
    Aug 19, 2003
  2. gaurav kashyap
    Replies:
    3
    Views:
    6,609
    Paul Boddie
    Oct 31, 2008
  3. Steve
    Replies:
    2
    Views:
    915
    edicionsdigitals.com edicions digitals xarxa socia
    Dec 7, 2010
  4. Carcarius
    Replies:
    0
    Views:
    270
    Carcarius
    Dec 6, 2007
  5. Mike
    Replies:
    2
    Views:
    144
Loading...

Share This Page