# Execute a file on read?

**URL:** <https://www.ruby-forum.com/t/execute-a-file-on-read/74858>\
**Category:** Ruby\
**Created:** [November 7, 2006, 10:59am UTC](https://www.ruby-forum.com/t/execute-a-file-on-read/74858 "2006-11-07T10:59:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eddieroger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/edb3f5/32.png) [@eddieroger](https://www.ruby-forum.com/u/eddieroger)\
**Post date:** [November 7, 2006, 10:59am UTC](https://www.ruby-forum.com/t/execute-a-file-on-read/74858/1 "2006-11-07T10:59:22Z")

</div>

I am toying around with the concept of dynamic configuration files for  
Asterisk ([http://www.asterisk.org](http://www.asterisk.org)), and I was wondering if its possible  
to have a dynamic file that’s executed on read. Basicly, when executed,  
the script would output a file that Asterisk is happy with, and  
preferably the file could have the extension “.conf”, but inside would  
be Ruby code. Is this possible, or am I pipe dreaming? Thanks.

Eddie

---

<div class="post-metadata">

**Author:** ![eddieroger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/edb3f5/32.png) [@eddieroger](https://www.ruby-forum.com/u/eddieroger)\
**Post date:** [November 7, 2006, 10:59am UTC](https://www.ruby-forum.com/t/execute-a-file-on-read/74858/2 "2006-11-07T10:59:23Z")

</div>

You want Unix fifos (man mkfifo) coupled with a Ruby program that opens  
the fifo for writing and dumps config file contents to any ‘client’.

eddieroger wrote:

> 

* * *

[MLB.com](http://MLB.com): Where Baseball is Always On

---

<div class="post-metadata">

**Author:** ![eddieroger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/edb3f5/32.png) [@eddieroger](https://www.ruby-forum.com/u/eddieroger)\
**Post date:** [November 7, 2006, 10:59am UTC](https://www.ruby-forum.com/t/execute-a-file-on-read/74858/3 "2006-11-07T10:59:29Z")

</div>

On 11/3/06, eddieroger [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am toying around with the concept of dynamic configuration files for  
> Asterisk ([http://www.asterisk.org](http://www.asterisk.org)), and I was wondering if its possible  
> to have a dynamic file that’s executed on read. Basicly, when executed,  
> the script would output a file that Asterisk is happy with, and  
> preferably the file could have the extension “.conf”, but inside would  
> be Ruby code. Is this possible, or am I pipe dreaming? Thanks.

Something like:

File.open(“foo.conf”, “wb”) do |cf|  
cf.puts \<\<-EOS  
puts “Hello, Ruby.”  
EOS  
end  
load “foo.conf”

?

-austin
