I am trying to write a ruby script that will ssh on a server, run a given command, and Get the output from it. Even what I have achieved, has been taken from the book so far:
requires' $ expect_verbose = true PTY.spawn (" Ssh root @ xy "). Reader, Author, PID. Reader.expect (/ root @ xy's password:. * /) Writer.Books ("Password") Reader. Chief (/.*/) Writer.Putus ("LS-L") Reader. Expand (/.*/ => Answer = Reader.Gets says "Answer = # {Answer}" end
Unfortunately, I'm returning to everyone, this is:
Any ideas that I have done wrong and how to reduce it?
For this, I recommend using the Net-SSH gem: sudo gem install net-ssh
:
The code is slightly less: 'Net>
Comments
Post a Comment