Invoke command

Definition
invoke_command(command, options={}, &block)
Module
Capistrano::Configuration::Actions::Invocation
File
capistrano/configuration/actions/invocation.rb

This helper was originally intended to let task authors programmatically and easily determine whether to use sudo or not for a particular command. In practice, though, it's usefulness is rather limited. This helper may be deprecated and eventually removed in future releases. Its use is discouraged.

invoke_command "apachectl restart", :via => use_sudo ? :sudo : :run
invoke_command "cat /etc/passwd", :via => :sudo do |channel, stream, data|
  # ...
end

Note that the sudo support for invoke_command suffers from the same limitations as syntax #2 of the sudo. In general, it is more flexible to use run with an embedded sudo call, than to use invoke_command.

Arguments

This method takes exactly the same arguments as the run, with the addition of:

:via
The value of this option should be a symbol, either :run or :sudo, indicating which helper method should be used to invoke the command. If not given, this defaults to :run.

See Also