On SSHkit-Github it's says:
All backends support the execute(*args), test(*args) & capture(*args)
From SSHkit-Rubydoc, I understand that execute
is actually an alias to test
?
What is the difference between test
, execute
, capture
in Capistrano/SSHKit and when should I use either?
execute
just executes command.
raises error with non-0
exit.
test
method behaves exactly the same as execute
however it returns boolean (true
if command exits with a 0
exit, and false
otherwise). it'll usually be used for control flow in your tasks.
capture
method will execute the command on the first matching server, and will return the stdout
output of the command as a string. stderr
output will be ignored (use ls 2>&1
to redirect stderr to stdout).
raises error with non-0
exit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With