extending Rake with a method rshell

H

hemant

I want to extend Rake with a method rshell, which would enable anyone
to execute a command remotely on various UNIX boxes.

Also, if the command asks for input, then remote process's stdin
should be connected to current processes stdin. So, if the command
asks for input, user can type it from current machine.

I have looked into Net::SSH, but can't find a reliable way to
connecting remote processes stdin to current process.

Capastrino does something like this, but not sure how?

I am trying on these lines

module Rake
class RemoteShell
attr_accessor :remote_ip,:user,:password,:remote_shell,:channels
def start_ssh_session
@channels ||= []
@channels << Net::SSH.start(@remote_ip,@user,@password)
end

def r_shell command
# open a channel and execute the command
# remote process should be connected to current process stdin
end
end
end
 
H

hemant

I want to extend Rake with a method rshell, which would enable anyone
to execute a command remotely on various UNIX boxes.

Also, if the command asks for input, then remote process's stdin
should be connected to current processes stdin. So, if the command
asks for input, user can type it from current machine.

I have looked into Net::SSH, but can't find a reliable way to
connecting remote processes stdin to current process.

Capastrino does something like this, but not sure how?

I am trying on these lines

module Rake
class RemoteShell
attr_accessor :remote_ip,:user,:password,:remote_shell,:channels
def start_ssh_session
@channels ||= []
@channels << Net::SSH.start(@remote_ip,@user,@password)
end

def r_shell command
# open a channel and execute the command
# remote process should be connected to current process stdin
end
end
end

I have looked into rake/contrib/sshpublisher . Yet, I wonder, how
methods defined in classes like SshDirPublisher would MIXIN into rake.

Alternately I can simple write the method rshell,but then, I want to
reuse ssh connection for executing other commands also.

So, without polluting Rakefile with those details, ain't it possibly
that all those details could be tucked away in library which extends
Rake?
 
G

Gregory Brown

I have looked into rake/contrib/sshpublisher . Yet, I wonder, how
methods defined in classes like SshDirPublisher would MIXIN into rake.

In ruby, you can use mixins more-or-less anywhere
hello world
=> nil
 
H

hemant

In ruby, you can use mixins more-or-less anywhere

hello world
=> nil

Thanks Gregory, I guess I can easily handle how to extend Rake. My
chief problem is, right now how can i attach remote process's stdin to
current terminal's input.
 
G

Gregory Brown

Thanks Gregory, I guess I can easily handle how to extend Rake. My
chief problem is, right now how can i attach remote process's stdin to
current terminal's input.

There is a chance it might be in the Net::SSH manual. I'm not sure if
you've found this yet.

http://net-ssh.rubyforge.org/

Also, it might be worthwhile to look at the Capistrano source if it
has a feature similar to this.
 
H

Hemant Kumar

Gregory said:
There is a chance it might be in the Net::SSH manual. I'm not sure if
you've found this yet.

http://net-ssh.rubyforge.org/

Also, it might be worthwhile to look at the Capistrano source if it
has a feature similar to this.
Yes I have looked into Net::SSH and also have hacked with Capistrino.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,221
Messages
2,571,134
Members
47,748
Latest member
LyleMondra

Latest Threads

Top