From: lyrics Date: 2009-01-15T07:49:59+09:00 Subject: Re: Net::SSH serialized commands On 14 jan, 23:31, "Sebastian W." wrote: > lyrics wrote: > > On 14 jan, 22:12, "Sebastian W." wrote: > >> > end > >> could try just doing this: > > >> Net::SSH.start( addr, user, :password => passwd) do |session| > >> session.exec! ("service X restart; ") > >> end > >> -- > >> Posted viahttp://www.ruby-forum.com/. > > > Thanks for replying. > > The solution isn't suitable. > > I need to execute other commands on another ssh connexion. > > Actually, my code is more like this: > > > Net::SSH.start( addr, user, :password => passwd) do |session1| > >   Net::SSH.start( addr2, user2, :password => passwd2) do |session2| > >     session1.exec! ("service X restart;") > >     session2.exec! ("") > >     session1.exec! ("") > >   end > > end > > Hm...that looks a bit odd to me. Why do the sessions have to be nested? > > If you need to do more advanced stuff - which it sounds like - "exec!" > probably will not suffice as it is just a convenience method. > > Here is the Net::SSHv2 docs, they're very helpful:http://net-ssh.rubyforge.org/ssh/v2/api/index.html > > What you are likely looking for is to use Net::SSH::Multi (maybe), build > up an aggregated event loop, and then run it with the "loop" method. > > -- > Posted viahttp://www.ruby-forum.com/. Basically, I just want to manage 2 PCs. "sending command to PC1 wait until command finished sending command to PC2 wait until command finished sending command to PC1 wait until command finished" I thought open both sessions at the same time was a convenient way to open them only once.