[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

net/telnet problem

Mark Probert

9/9/2003 9:17:00 PM


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.

2 Answers

Rodrigo Bermejo

9/10/2003 12:14:00 AM

0

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.)
>
>
>



Mark Probert

9/10/2003 7:04:00 PM

0

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.