Guest User

Untitled

a guest
Mar 9th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. ## I'm lost with the exceptions here, where should they be placed? before
  2. ## or after the block?; i know they have to rescue the connection and authentication
  3.  
  4. begin
  5. Net::SSH.start( '192.168.1.101',:password=>'john',:port => 22,:username=>'user1') do |session|
  6. shell = session.shell.sync
  7. out = shell.send_command( "ls" )
  8. p out.stdout
  9. p shell.exit
  10. end
  11.  
  12. rescue SocketError
  13. raise(IOError, 'Could not connect to host')
  14. rescue Net::SSH::AuthenticationFailed
  15. raise(IOError, 'Authentication Failed')
  16. end
Add Comment
Please, Sign In to add comment