Method: Pike::SSH::Connection.try_sudo
- Defined in:
- lib/pike/ssh/connection.rb
.try_sudo ⇒ Object
Try’s sudo to ensure the password prompt will not pop again
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/pike/ssh/connection.rb', line 55 def try_sudo if @session Main.action "Trying sudo" do result = run("sudo echo 'ok'") if result.success? if result.stdout.strip.end_with?('ok') true else Main.error('Unexpected data received while trying sudo: ' + result.stderr) end else Main.error('sudo failed. Wrong password?') end end false else connection_error end end |