Module: Doorway::ExecAs

Defined in:
lib/doorway/commands/exec_as.rb

Instance Method Summary collapse

Instance Method Details

#escape_chars(command) ⇒ Object



6
7
8
# File 'lib/doorway/commands/exec_as.rb', line 6

def escape_chars(command)
  command.gsub('"', '\"').gsub('$', '\$')
end

#exec_as(user, command) ⇒ Object



2
3
4
# File 'lib/doorway/commands/exec_as.rb', line 2

def exec_as(user, command)
  exec %Q[sudo -i -u #{user} bash -c "#{escape_chars(command)}"]
end