【问题标题】:Shell execute from RubyShell 从 Ruby 执行
【发布时间】:2009-10-06 17:35:01
【问题描述】:

假设,我的 .rb 脚本中有一个文件“text_file.txt”。如何从 Ruby 执行该文件的默认 Windows 程序?

【问题讨论】:

    标签: ruby windows shell


    【解决方案1】:

    来自 IRB:

    system "start text_file.txt"
    

    从外壳:

    ruby -e 'system "start text_file.txt"'
    

    【讨论】:

      【解决方案2】:

      使用system 命令,如

      ruby -e 'system "ipconfig"'
      

      【讨论】:

        猜你喜欢
        • 2014-12-29
        • 2015-11-14
        • 1970-01-01
        • 2013-07-29
        • 1970-01-01
        • 2011-10-22
        • 1970-01-01
        • 1970-01-01
        • 2015-08-29
        相关资源
        最近更新 更多