Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Executing a Ruby script from Asterisk (See related posts)

To run a Ruby script from Asterisk you need 2 things 1) an extension to run the script from 2) a Ruby script.

* Preparing the evironment *
1) create a script directory for Asterisk and ensure it has permission to run the scripts.

* Running the script *
1) Dial extension 3000
2) Listen to the voice say 'hello world'
3) Observe a new output.txt file has been created containing the message 'hello world!'

file: hello-world.rb
#!/usr/bin/ruby

#file : hello-world.rb

file = File.new('/etc/asterisk/ruby/output.txt','w')
file.puts 'hello world!'
file.close

file: extensions.rb
exten => 3000,1,Playback(hello-world)
exten => 3000,n,System(/etc/asterisk/ruby/./hello-world.rb)
exten => 3000,n,Hangup


file: output.txt
hello world!

Comments on this post

asil posts on Oct 24, 2009 at 09:43
Thank you for sharing and technical informations. This article I want to share with my other friends. Regards.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Paylasmak icin chat odaları, turkce sohbet deneyin.
yaohao posts on Nov 05, 2009 at 11:25


Hi, everybody here, I just spent more treplica handbags
replica bags
ed hardy
ed hardy clothing
ralph lauren polo
juicy couturehan 1000 USD in and bought one gift for my wife, I think it’s worth and the bag drives my wife crazy.

You need to create an account or log in to post comments to this site.


Click here to browse all 7308 code snippets

Related Posts