net-ssh : popen3

  • Thread starter Philip Müller
  • Start date
P

Philip Müller

Hi everybody,

I want to start and interact with a process on another machine.
After reading example 20.10 in "The Ruby Cookbook" and doing some internet
research I decided to use net/ssh and popen3.
Sadly, it does not work - it just doesn't do anything noticeable, it
doesn't even terminate.

Here's my code:

----------- CODE ----------------

require 'rubygems'
require 'net/ssh'

def run_remotely(command)
Net::SSH.start("localhost", "tester", :password => "pass") do |session|
session.process.popen3(command) do |stdin, stdout, stderr|
yield stdin, stdout, stderr
end
end
end

run_remotely('cat') do |stdin, stdout, stderr|
stdin.puts 'Line one.\n'
end

----------- /CODE ----------------

Why doesn't this work?


Thanks,

Philip

P.s.:
I have successfully used channel.exec to execute "ls", but it doesn't seem
like it allows two-way communication.
 
P

Philip Müller

Sorry...
run_remotely('cat') do |stdin, stdout, stderr|
stdin.puts 'Line one.\n'
end

is supposed to be

run_remotely('cat') do |stdin, stdout, stderr|
stdin.puts 'Line one.\n'
puts stdout.read
end


Regards

Philip
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top