Question about net-ssh

Hi guys,

I am learning ssh module. I have a question about the channel.
Please kindly give me some tips if you are familiar with this module.
Thank you in advice!! :slight_smile:

Code slice:

Net::SSH.start(host,user,:password=>pass) do |ssh|
ssh.open_channel do |channel|
channel.on_data do |ch, data|
if data =~ /Done/
ch.exec(“command2”) --here is the question
end
end
channel.exec(“command1”) --cmd1 will return different result
end
end

Can I invoke exec(channel) twice in one channel?
If not, what is the use for “ch” variable here.