As the net-ssh manual book says the method "exec" executes a command asynchronously on channel.http://net-ssh.github.io/ssh/v1/chapter-3.html#s6
But when I hope to execute some instructors in order, for example:
def work(session, instructor )
session.open_channel do |channel|
channel.on_data do |ch, data|
puts data.strip
end
channel.exec instructor
end
end
Net::SSH.start( 'host' ) do |session|
work session, "touch a.file"
work session, "mv a.file b.file"
work session, "rm b.file"
session.loop
end
Executing a command asynchronously really makes such code doesn't work.
Can anybody help me to solve this problem?
Thanks!