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.
8 9 10 11 12 13 14 15 |
# File 'lib/ssh_smart.rb', line 8 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.
6 7 8 |
# File 'lib/ssh_smart.rb', line 6 def host @host end |
#inbox ⇒ Object
Returns the value of attribute inbox.
6 7 8 |
# File 'lib/ssh_smart.rb', line 6 def inbox @inbox end |
#login ⇒ Object
Returns the value of attribute login.
6 7 8 |
# File 'lib/ssh_smart.rb', line 6 def login @login end |
#outbox ⇒ Object
Returns the value of attribute outbox.
6 7 8 |
# File 'lib/ssh_smart.rb', line 6 def outbox @outbox end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/ssh_smart.rb', line 6 def password @password end |
#work ⇒ Object
Returns the value of attribute work.
6 7 8 |
# File 'lib/ssh_smart.rb', line 6 def work @work end |
Instance Method Details
#checkFolderFile(dirFile, fileName) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# 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 if result.include? fileName method = true end method end |
#copyFileToRemote(fileRemote) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ssh_smart.rb', line 17 def copyFileToRemote(fileRemote) method = false Net::SCP.start(@host, @login, :password => @password) do |scp| scp.upload(fileRemote, @inbox) end if checkFolderFile(@outbox, File.basename(fileRemote)) method = true end method end |
#retornar ⇒ Object
41 42 43 |
# File 'lib/ssh_smart.rb', line 41 def retornar puts 'Funcionando!!' end |