# Problem in calling the script written in other file

**URL:** <https://rubytalk.org/t/problem-in-calling-the-script-written-in-other-file/45735>\
**Category:** ruby-talk\
**Created:** [8 April 2008 06:13 UTC](https://rubytalk.org/t/problem-in-calling-the-script-written-in-other-file/45735 "2008-04-08T06:13:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pranjal\_Jain](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@Pranjal\_Jain](https://rubytalk.org/u/Pranjal_Jain)\
**Post date:** [8 April 2008 06:13 UTC](https://rubytalk.org/t/problem-in-calling-the-script-written-in-other-file/45735/1 "2008-04-08T06:13:49Z")

</div>

Dear ALL  
Hi,  
I am practicing Ruby from the last 2 weeks.  
I am trying to call the script in one file to the script written in  
other file.

I had written a script in test.rb  
The script is as follows :

> **···**
>
> #######################################################################
> 
> &nbsp;&nbsp;def test\_b\_count
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sleep 2
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts "\n\nNumber of links on the web page are :" "  
> #{$ie.links.length}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts "\nNumber of divisions on the web page are :" "  
> #{$ie.divs.length}"
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;all\_links\_href = Array.new
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ie.links.each {|link| all\_links\_href \<\< link.href}  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#puts all\_links\_href  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i = 0  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;until i \> $ie.links.length  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$worksheet\_two.Range("a#{i+1}").value = all\_links\_href[i]  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i += 1  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j = 0  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;until j \> $ie.links.length  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ie.goto "$worksheet\_two.Range(a#{j+1}).Value"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if $ie.h2(:text,"Error 404--Not Found" ).exists?  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$worksheet\_two.Range("b#{j+1}").Value = "Fail"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$worksheet\_two.Range("b#{j+1}").Value = "Pass"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j += 1  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> end  
> #############################################################
> 
> I am trying to call this script in other file called login.rb
> 
> But i am getting the error:
> 
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
> 'gem\_original\_require': ./test.rb:4:syntax error, unexpected  
> kIN,expecting $end(SyntaxError)  
> Finished in 3.469 seconds.  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from  
> c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in 'require  
> from login.rb : 6  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> Please help.  
> Thanks in advance  
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Matt9](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Matt9](https://rubytalk.org/u/Matt9)\
**Post date:** [9 April 2008 17:40 UTC](https://rubytalk.org/t/problem-in-calling-the-script-written-in-other-file/45735/2 "2008-04-09T17:40:06Z")

</div>

The test.rb script script as you've shown it here is faulty (too many  
"end" lines). m.

> **···**
>
> Pranjal Jain \<pranjal.jain123@gmail.com\> wrote:
> 
> > Dear ALL  
> > Hi,  
> > I am practicing Ruby from the last 2 weeks.  
> > I am trying to call the script in one file to the script written in  
> > other file.
> > 
> > I had written a script in test.rb  
> > The script is as follows :  
> > #######################################################################
> > 
> > &nbsp;&nbsp;def test\_b\_count
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sleep 2
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts "\n\nNumber of links on the web page are :" "  
> > #{$ie.links.length}"  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts "\nNumber of divisions on the web page are :" "  
> > #{$ie.divs.length}"
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;all\_links\_href = Array.new
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ie.links.each {|link| all\_links\_href \<\< link.href}  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#puts all\_links\_href  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i = 0  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;until i \> $ie.links.length  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$worksheet\_two.Range("a#{i+1}").value = all\_links\_href[i]  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i += 1  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j = 0  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;until j \> $ie.links.length  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ie.goto "$worksheet\_two.Range(a#{j+1}).Value"  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if $ie.h2(:text,"Error 404--Not Found" ).exists?  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$worksheet\_two.Range("b#{j+1}").Value = "Fail"  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$worksheet\_two.Range("b#{j+1}").Value = "Pass"  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j += 1  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> > end  
> > #############################################################
> > 
> > I am trying to call this script in other file called login.rb
> > 
> > But i am getting the error:
> > 
> > \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> > 
> > c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
> > 'gem\_original\_require': ./test.rb:4:syntax error, unexpected  
> > kIN,expecting $end(SyntaxError)  
> > Finished in 3.469 seconds.  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from  
> > c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in 'require  
> > from login.rb : 6  
> > \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> > 
> > Please help.
> 
> --  
> matt neuburg, phd = matt@tidbits.com, [Matt Neuburg’s Home Page](http://www.tidbits.com/matt/)  
> Leopard - [http://www.takecontrolbooks.com/leopard-customizing.html](http://www.takecontrolbooks.com/leopard-customizing.html)  
> AppleScript - [http://www.amazon.com/gp/product/0596102119](http://www.amazon.com/gp/product/0596102119)  
> Read TidBITS! It's free and smart. [http://www.tidbits.com](http://www.tidbits.com)
