Capture

Definition
capture(command, options={})
Module
Capistrano::Configuration::Actions::Inspect
File
capistrano/configuration/actions/inspect.rb

The capture helper will execute the given command on the first matching server, and will return the output of the command as a string.

version = capture("cat /u/apps/social/current/REVISION")

Arguments

command

This must be a string containing the shell command (or commands) to execute. It has identical semantics and syntax to the command argument for the run helper.

options

See run for a full description of all supported options. The only exception is the :once option, which capture ignores. (It will only run on the first matching server, regardless of the value of the :once option.)

Caveats

The capture helper will only return output that the command emits on stdout. Anything sent via stderr will be echoed to the terminal and otherwise ignored. If you wish to capture both stderr and stdout, you'll need to redirect stderr to stdout:

whole_enchilada = capture("ls -l / 2>&1")

See Also