Make terminal talk from a ruby script

This question already has an answer here:

  • Calling shell commands from Ruby 19 answers

  • The most simplistic way to call commands from ruby is with backticks.

    For example,

    def say_hello
        `say hello`
    end
    

    Would run the command say hello in terminal.

    Testing this in IRB causes the computer to say "Hello".

    You might want to look into alternate methods of calling the command line though, as backticks aren't the most secure.

    链接地址: http://www.djcxy.com/p/25286.html

    上一篇: 在ruby代码中使用终端命令?

    下一篇: 从ruby脚本进行终端通话