[英]What is the difference between execute, test and capture commands in Capistrano?
On SSHkit-Github it's says: 在SSHkit-Github上它说:
All backends support the execute(*args), test(*args) & capture(*args)
所有后端都支持执行(* args),test(* args)和capture(* args)
From SSHkit-Rubydoc , I understand that execute
is actually an alias to test
? 从SSHkit-Rubydoc ,我知道
execute
实际上是一个别名来test
?
What is the difference between test
, execute
, capture
in Capistrano / SSHKit and when should I use either? 在Capistrano / SSHKit中
test
, execute
, capture
之间有什么区别?我应该何时使用?
execute just executes command. 执行只执行命令。 raises error with non-
0
exit. 非
0
退出时引发错误。
test method behaves exactly the same as execute
however it returns boolean ( true
if command exits with a 0
exit, and false
otherwise). test方法的行为与
execute
完全相同,但它返回boolean(如果命令以0
退出退出,则返回true
否则返回false
)。 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. capture方法将在第一个匹配服务器上执行该命令,并将该命令的
stdout
输出作为字符串返回。 stderr
output will be ignored (use ls 2>&1
to redirect stderr to stdout). stderr
输出将被忽略(使用ls 2>&1
将stderr重定向到stdout)。 raises error with non- 0
exit. 非
0
退出时引发错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.