Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the easiest way I can create a 'beep' sound from a Ruby program?

Tags:

ruby

beep

I'm making a small ruby command line script and I wanted to know what the simplest way to have the program emit a beep is.

like image 563
Daniel X Moore Avatar asked Mar 07 '09 04:03

Daniel X Moore


People also ask

What is a beep command?

beep allows the user to control the pc-speaker with precision, allowing different sounds to indicate different events. While it can be run quite happily on the command line, it's intended place of residence is within shell/perl scripts, notifying the user when something interesting occurs.


2 Answers

Try printing the audible bell character:

print "\a" 
like image 173
Paige Ruten Avatar answered Oct 13 '22 06:10

Paige Ruten


For Mac OS X:

system('say "beep"') 

Conventional print "\a" didn't always work by some reason for me (MBA, 10.7.4)

like image 43
Andrei Avatar answered Oct 13 '22 06:10

Andrei