Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > net/telnet problem

Reply
Thread Tools

net/telnet problem

 
 
Mark Probert
Guest
Posts: n/a
 
      09-09-2003

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.

 
Reply With Quote
 
 
 
 
Bermejo, Rodrigo
Guest
Posts: n/a
 
      09-10-2003
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.)
>
>
>




 
Reply With Quote
 
 
 
 
Mark Probert
Guest
Posts: n/a
 
      09-10-2003
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments