2

How can I run the OS X command say (man page) inside a Ruby shell script without exiting that script? The advice in the thread Calling shell commands from Ruby doesn't seem to apply.

Community
  • 1
  • 1
hjkml
  • 253
  • 3
  • 8

2 Answers2

3

You want

`say "#{var_name}"`

If you find backticks hard to read

%x(say "#{var_name}")

This would work as well:

system "say", var_name
glenn jackman
  • 238,783
  • 38
  • 220
  • 352
1

You can do it like this:

message = "Hello world"

`say "#{message}"`
Tim Destan
  • 2,028
  • 12
  • 16