BTW, you shouldn't need to combine su and sudo, they both do roughly
the same thing. Instead of using su, you could just use sudo to run
the command, su is redundant in this case. I think what you want might
be:
run "sudo -u svcuser whoami"
This will run the command whoami as the user svcuser. Ensure that
/etc/sudoers allows the whoami command to run.
Paul
# channel: the SSH channel object used for this response
# stream: either :err or :out, for stderr or stdout responses
# output: the text that the server is sending, might be in chunks
run "apt-get update" do |channel, stream, output|
if output =~ /Are you sure?/
answer = Capistrano::CLI.ui.ask("Are you sure: ")
channel.send_data(answer + "\n")
else
# allow the default callback to be processed
Capistrano::Configuration.default_io_proc.call[channel, stream, output]
end
end