What is the difference between execute, test and capture commands in Capistrano?
Asked Answered
D

1

6

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?

Destined answered 21/9, 2015 at 16:41 Comment(0)
D
12

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.

Destined answered 6/11, 2015 at 5:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.