简体   繁体   English

Capistrano中执行,测试和捕获命令有什么区别?

[英]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中 testexecutecapture之间有什么区别?我应该何时使用?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM