Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 970
lakesare Avatar asked Sep 21 '15 16:09

lakesare


1 Answers

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.

like image 141
lakesare Avatar answered Sep 22 '22 02:09

lakesare