How to call shell commands from Ruby

前端 未结 20 2073
旧时难觅i
旧时难觅i 2020-11-22 01:10

How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby?

20条回答
  •  太阳男子
    2020-11-22 01:48

    Here's a cool one that I use in a ruby script on OS X (so that I can start a script and get an update even after toggling away from the window):

    cmd = %Q|osascript -e 'display notification "Server was reset" with title "Posted Update"'|
    system ( cmd )
    

提交回复
热议问题