# Require question

**URL:** <https://www.ruby-forum.com/t/require-question/147292>\
**Category:** Ruby\
**Created:** [August 30, 2008, 1:28pm UTC](https://www.ruby-forum.com/t/require-question/147292 "2008-08-30T13:28:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lpc2148](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9de053/32.png) [@lpc2148](https://www.ruby-forum.com/u/lpc2148)\
**Post date:** [August 30, 2008, 1:28pm UTC](https://www.ruby-forum.com/t/require-question/147292/1 "2008-08-30T13:28:14Z")

</div>

Hi guys!

I’m trying to write a simple source filter . For that purpose I created  
a module which , when included into a script , it should filter the  
operations .This is the filter module

module Filter  
def self.recreate(file)  
lines = File.read(file)  
puts lines  
raise SystemExit  
end  
end

if( **FILE**!= $0)  
Filter.recreate($0)  
end

and this is the script :

require “filter”

[shell]some shell command goes here[/shell]

If i’m running the script directly (ruby script.rb), I’m receiving the  
following error :  
z.rb:3: syntax error, unexpected tIDENTIFIER, expecting $end  
[shell]some shell command goes here[/shell]

I understand that ruby gives me an error , but I thoght that because the  
Filter module kicks in first , it can process the source file before it  
reaches the interpreter .

If I run the script like : ruby -rfilter script.rb , I see the output  
of the script on the console . How could I make the script behave that  
way just by including the

require “filter”

line? I hope there is another solution than :  
#!/usr/bin/ruby -rfilter

Thanks
