[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

net/telnet

pedro.baldanta@gmail.com

8/10/2006 9:35:00 AM

Hi all:

I was unable to start "su -" after open telnet conexion. I got:

:-================ Timeout::Error =====================
C:\ruby\lib\ruby\1.8/net/telnet.rb:551:in `waitfor'
raise TimeoutError, "timed out while waiting for more
data"
C:\ruby\lib\ruby\1.8/net/telnet.rb:680:in `cmd'
waitfor({"Prompt" => match, "Timeout" => time_out})
C:\Documents and Settings\admin\Escritorio\telne_test.rb:12
localhost.cmd("su -")
C:\ruby\lib\ruby\site_ruby\1.8/rubygems/custom_require.rb:27:in
`require'
gem_original_require path

=============================================
Exception: timed out while waiting for more data


Any idea?

5 Answers

Nobuyoshi Nakada

8/10/2006 10:50:00 AM

0

Hi,

At Thu, 10 Aug 2006 18:35:05 +0900,
pedro.baldanta@gmail.com wrote in [ruby-talk:207510]:
> I was unable to start "su -" after open telnet conexion. I got:
>
> :-================ Timeout::Error =====================
> C:\ruby\lib\ruby\1.8/net/telnet.rb:551:in `waitfor'
> raise TimeoutError, "timed out while waiting for more
> data"
> C:\ruby\lib\ruby\1.8/net/telnet.rb:680:in `cmd'
> waitfor({"Prompt" => match, "Timeout" => time_out})
> C:\Documents and Settings\admin\Escritorio\telne_test.rb:12
> localhost.cmd("su -")

In common, the prompt of superuser differs from ordinary users.

--
Nobu Nakada

Yoann Guillot

8/10/2006 10:53:00 AM

0

On Thu, Aug 10, 2006 at 06:35:05PM +0900, pedro.baldanta@gmail.com wrote:
> Hi all:
>
> I was unable to start "su -" after open telnet conexion. I got:
>
> :-================ Timeout::Error =====================
> C:\ruby\lib\ruby\1.8/net/telnet.rb:551:in `waitfor'
> raise TimeoutError, "timed out while waiting for more
> data"
> C:\ruby\lib\ruby\1.8/net/telnet.rb:680:in `cmd'
> waitfor({"Prompt" => match, "Timeout" => time_out})
> C:\Documents and Settings\admin\Escritorio\telne_test.rb:12
> localhost.cmd("su -")
> C:\ruby\lib\ruby\site_ruby\1.8/rubygems/custom_require.rb:27:in
> `require'
> gem_original_require path
>
> =============================================
> Exception: timed out while waiting for more data
>
>
> Any idea?
>
>

Telnet uses a regex to match the shell prompt, so that it knows that the
preceding command has terminated.
When you 'su -', you change the prompt (probably a $ becomes a #, or
your login changes), so Telnet never sees the end of the 'su -' command.
You should change the regex used to match the prompt when you create the
Net::Telnet object, so that it matches both your normal prompt and the
root prompt, i.e

conn = Net::Telnet.new('Host' => 'bla', 'Prompt' => /me@host\$|root@host#/)

Yoann

M. Edward (Ed) Borasky

8/10/2006 1:19:00 PM

0

Yoann Guillot wrote:
> On Thu, Aug 10, 2006 at 06:35:05PM +0900, pedro.baldanta@gmail.com wrote:
>
>> Hi all:
>>
>> I was unable to start "su -" after open telnet conexion. I got:
>>
>> :-================ Timeout::Error =====================
>> C:\ruby\lib\ruby\1.8/net/telnet.rb:551:in `waitfor'
>> raise TimeoutError, "timed out while waiting for more
>> data"
>> C:\ruby\lib\ruby\1.8/net/telnet.rb:680:in `cmd'
>> waitfor({"Prompt" => match, "Timeout" => time_out})
>> C:\Documents and Settings\admin\Escritorio\telne_test.rb:12
>> localhost.cmd("su -")
>> C:\ruby\lib\ruby\site_ruby\1.8/rubygems/custom_require.rb:27:in
>> `require'
>> gem_original_require path
>>
>> =============================================
>> Exception: timed out while waiting for more data
>>
>>
>> Any idea?
>>
>>
>>
>
> Telnet uses a regex to match the shell prompt, so that it knows that the
> preceding command has terminated.
> When you 'su -', you change the prompt (probably a $ becomes a #, or
> your login changes), so Telnet never sees the end of the 'su -' command.
> You should change the regex used to match the prompt when you create the
> Net::Telnet object, so that it matches both your normal prompt and the
> root prompt, i.e
>
> conn = Net::Telnet.new('Host' => 'bla', 'Prompt' => /me@host\$|root@host#/)
>
> Yoann
>
>
>
IIRC there's a "standard" regex one uses that will match most common
UNIX prompts, but I can't remember what it is. It includes "\$" and "#"
and "%", but I don't remember what else there is.

Nobuyoshi Nakada

8/10/2006 1:43:00 PM

0

Hi,

At Thu, 10 Aug 2006 22:18:38 +0900,
M. Edward (Ed) Borasky wrote in [ruby-talk:207547]:
> IIRC there's a "standard" regex one uses that will match most common
> UNIX prompts, but I can't remember what it is. It includes "\$" and "#"
> and "%", but I don't remember what else there is.

"#" is for super user. "$" and "%" are for ordinary users, and
defaults in Bourne shell and C shell respectively.

--
Nobu Nakada

Prasad Pednekar

1/15/2008 1:06:00 PM

0

Hey,
The default Prompt value can be the one given below in the new
method :

"Prompt" => /[$%#>] \z/n


Regards,
Prasad.
--
Posted via http://www.ruby-....