开发者

How do I tell from within a ruby script whether it has been run from the command line or from a non-interactive process?

开发者 https://www.devze.com 2023-01-07 17:50 出处:网络
How do I tell from within a ruby script whether it has been run from the command line, i.e. like this:

How do I tell from within a ruby script whether it has been run from the command line, i.e. like this:

> ruby myscript.rb

or from a non-interactive process, e.g. cron?开发者_JAVA技巧


$stdin.tty? will return true if connected to a terminal otherwise false.

There is a fair bit of additional information on question Best practices with STDIN in Ruby?

0

精彩评论

暂无评论...
验证码 换一张
取 消