可以直接透過 ruby 來執行 commands 的指令。
- Kernel#`, commonly called backticks
Returns the result of the shell command.
1 2 3 4 |
|
%x(cmd)
跟上面的 ` 是類似
Returns the result of the shell command, just like the backticks. 會以字串形式回傳結果
1 2 |
|
Kernel#system
指令執行結果成功與否,回傳的是布林值
Return: true if the command was found and ran successfully, false otherwise
1 2 3 4 |
|
Kernel#exec
會中斷當前的 process
Return: none, the current process is replaced and never continues
1 2 |
|
官方文件:
參考文件: