net/telnet problem

Discussion in 'Ruby' started by Mark Probert, Sep 9, 2003.

  1. Mark Probert

    Mark Probert Guest

    Hi.

    I am not sure how to handle this telnet problem. Any ideas appreciated.

    I am running a telnet command that has a pager enabled (there is no way
    not to have the pager enabled). The output is something like:

    Tue 09-Sep-2003 16:56:01 blah blah
    Tue 09-Sep-2003 16:56:02 foo bar
    --More--('q' to end display)

    Except that the '--More-- etc' part is -not- part of the output stream.

    So, I try and get around it by setting a specific timeout and catching
    the exception. Except I seem not to be able to get the data.

    begin
    str = @conn.waitfor('Match' => /\#/,
    'Timeout' => 15)
    puts str
    rescue TimeoutError => e
    puts str
    puts "attempting to terminate!!!!"
    @conn.write("q\n")
    @conn.waitfor(/\#/) { |str| puts str }
    end

    (A bit hacked from the real code, however the idea is there.)

    --
    -mark.
    Mark Probert, Sep 9, 2003
    #1
    1. Advertising

  2. assuming you are on *ix.

    Have you tried changing your PAGER settings ?
    export PAGER=cat

    or you can create a suicidal shell script which invokes the application

    @conn.cmd("sh sucidal_script.sh")

    -rbermejo

    Mark Probert wrote:

    >Hi.
    >
    >I am not sure how to handle this telnet problem. Any ideas appreciated.
    >
    >I am running a telnet command that has a pager enabled (there is no way
    >not to have the pager enabled). The output is something like:
    >
    > Tue 09-Sep-2003 16:56:01 blah blah
    > Tue 09-Sep-2003 16:56:02 foo bar
    > --More--('q' to end display)
    >
    >Except that the '--More-- etc' part is -not- part of the output stream.
    >
    >So, I try and get around it by setting a specific timeout and catching
    >the exception. Except I seem not to be able to get the data.
    >
    > begin
    > str = @conn.waitfor('Match' => /\#/,
    > 'Timeout' => 15)
    > puts str
    > rescue TimeoutError => e
    > puts str
    > puts "attempting to terminate!!!!"
    > @conn.write("q\n")
    > @conn.waitfor(/\#/) { |str| puts str }
    > end
    >
    >(A bit hacked from the real code, however the idea is there.)
    >
    >
    >
    Bermejo, Rodrigo, Sep 10, 2003
    #2
    1. Advertising

  3. Mark Probert

    Mark Probert Guest

    Hi, Rodrigo.

    > assuming you are on *ix.
    >


    Alas, this not the case ...

    Taking the 'catch the timeout' seems to be working ok, so I'll go with that
    until something better spring to mind.


    --
    -mark.
    Mark Probert, Sep 10, 2003
    #3
    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. Jim Isaacson
    Replies:
    5
    Views:
    603
    Default User
    Nov 5, 2004
  2. Carcarius
    Replies:
    0
    Views:
    294
    Carcarius
    Dec 6, 2007
  3. Josh Hurtado

    Net::Telnet into Net::SSH

    Josh Hurtado, May 26, 2011, in forum: Ruby
    Replies:
    4
    Views:
    617
    Brian Candler
    May 27, 2011
  4. Jim Mozley

    Net::Telnet and waitfor context problem

    Jim Mozley, Sep 5, 2003, in forum: Perl Misc
    Replies:
    5
    Views:
    233
    Jim Mozley
    Sep 5, 2003
  5. Net::Telnet prompt problem

    , Apr 13, 2005, in forum: Perl Misc
    Replies:
    2
    Views:
    208
Loading...

Share This Page