lib/serverspec/helper.rb in serverspec-0.0.3 vs lib/serverspec/helper.rb in serverspec-0.0.4
- old
+ new
@@ -5,13 +5,13 @@
module Helper
def ssh_exec(host, cmd, opt={})
options = Net::SSH::Config.for(host)
user = options[:user] || Etc.getlogin
- ret = {}
+ ret = nil
Net::SSH.start(host, user, options) do |ssh|
- ret = ssh_exec!(ssh, cmd)
+ ret = ssh_exec!(ssh, "sudo #{cmd}")
end
ret
end
private
@@ -19,13 +19,14 @@
stdout_data = ''
stderr_data = ''
exit_code = nil
exit_signal = nil
ssh.open_channel do |channel|
- channel.exec(command) do |ch, success|
- unless success
- abort "FAILED: couldn't execute command (ssh.channel.exec)"
- end
+ channel.request_pty do |ch, success|
+ abort "Could not obtain pty " if !success
+ end
+ channel.exec("#{command}") do |ch, success|
+ abort "FAILED: couldn't execute command (ssh.channel.exec)" if !success
channel.on_data do |ch,data|
stdout_data += data
end
channel.on_extended_data do |ch,type,data|