Class: SSH
- Inherits:
-
Object
- Object
- SSH
- Defined in:
- lib/ssh_smart.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#inbox ⇒ Object
Returns the value of attribute inbox.
-
#login ⇒ Object
Returns the value of attribute login.
-
#outbox ⇒ Object
Returns the value of attribute outbox.
-
#password ⇒ Object
Returns the value of attribute password.
-
#work ⇒ Object
Returns the value of attribute work.
Instance Method Summary collapse
- #checkFolderFile(dirFile, fileName) ⇒ Object
- #copyFileToRemote(fileRemote) ⇒ Object
-
#initialize(host, login, password, inbox, work, outbox) ⇒ SSH
constructor
A new instance of SSH.
- #retornar ⇒ Object
Constructor Details
#initialize(host, login, password, inbox, work, outbox) ⇒ SSH
Returns a new instance of SSH.
10 11 12 13 14 15 16 17 |
# File 'lib/ssh_smart.rb', line 10 def initialize(host, login, password, inbox, work, outbox) @host = host @login = login @password = password @inbox = inbox @work = work @outbox = outbox end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/ssh_smart.rb', line 8 def host @host end |
#inbox ⇒ Object
Returns the value of attribute inbox.
8 9 10 |
# File 'lib/ssh_smart.rb', line 8 def inbox @inbox end |
#login ⇒ Object
Returns the value of attribute login.
8 9 10 |
# File 'lib/ssh_smart.rb', line 8 def login @login end |
#outbox ⇒ Object
Returns the value of attribute outbox.
8 9 10 |
# File 'lib/ssh_smart.rb', line 8 def outbox @outbox end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/ssh_smart.rb', line 8 def password @password end |
#work ⇒ Object
Returns the value of attribute work.
8 9 10 |
# File 'lib/ssh_smart.rb', line 8 def work @work end |
Instance Method Details
#checkFolderFile(dirFile, fileName) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ssh_smart.rb', line 28 def checkFolderFile(dirFile, fileName) returnMethod = false result = '' method = false Net::SSH.start(@host, @login, password: @password) do |ssh| result = ssh.exec!("cd #{dirFile} && ls") end method = true if result.include? fileName method end |
#copyFileToRemote(fileRemote) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/ssh_smart.rb', line 19 def copyFileToRemote(fileRemote) method = false Net::SCP.start(@host, @login, password: @password) do |scp| scp.upload(fileRemote, @inbox) end method = true if checkFolderFile(@outbox, File.basename(fileRemote)) method end |
#retornar ⇒ Object
39 40 41 |
# File 'lib/ssh_smart.rb', line 39 def retornar puts 'Funcionando!!' end |