[lnkForumImage]
TotalShareware - Download Free Software

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


 

Gonçalo Pires

2/10/2009 1:59:00 AM

[Note: parts of this message were removed to make it a legal post.]

Hi there,

I'm trying to develop a script that will use net-ssh to performe some
routine commands on a remote server.

But i've a problem when i give a comand that will change the remote system
prompt. I think ruby is expecting the default caracter "#", but the command
will change it to ">", and the script don't run.

require 'net/ssh'
Net::SSH.start('172.16.20.78', 'root', :password => "passwd" ) do |
ssh|
output = ssh.exec!("su - sysad")
end

Could you please tell me I could I change the "expected" prompt?

Best regards,
GP

2 Answers

Gonçalo Pires

2/12/2009 8:26:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

> Hi there,
>
> I'm trying to develop a script that will use net-ssh to performe some
> routine commands on a remote server.
>
> But i've a problem when i give a comand that will change the remote system
> prompt. I think ruby is expecting the default caracter "#", but the command
> will change it to ">", and the script don't run.
>
> require 'net/ssh'
> Net::SSH.start('172.16.20.78', 'root', :password => "passwd" ) do |
> ssh|
> output = ssh.exec!("su - sysad")
> end
>
> Could you please tell me how could I change the "expected" prompt?
>
> Best regards,
> GP
>
>

Brian Candler

2/15/2009 8:50:00 PM

0

Gonçalo Pires wrote:
> Hi there,
>
> I'm trying to develop a script that will use net-ssh to performe some
> routine commands on a remote server.
>
> But i've a problem when i give a comand that will change the remote
> system
> prompt. I think ruby is expecting the default caracter "#", but the
> command
> will change it to ">", and the script don't run.
>
> require 'net/ssh'
> Net::SSH.start('172.16.20.78', 'root', :password => "passwd" ) do |
> ssh|
> output = ssh.exec!("su - sysad")
> end
>
> Could you please tell me I could I change the "expected" prompt?

I don't think raw Net::SSH waits for a prompt. It works at a lower level
of the SSH protocol protocol units.

If you want an expect-like interface, you could try Net::SSH::Telnet
(separate package). This is something I wrote to give an API almost
identical to Net::Telnet.
--
Posted via http://www.ruby-....