# CGI with Ruby

**URL:** <https://www.ruby-forum.com/t/cgi-with-ruby/97985>\
**Category:** Ruby\
**Created:** [July 11, 2006, 9:20pm UTC](https://www.ruby-forum.com/t/cgi-with-ruby/97985 "2006-07-11T21:20:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harish\_TM](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/46a35a/32.png) [@Harish\_TM](https://www.ruby-forum.com/u/Harish_TM)\
**Post date:** [July 11, 2006, 9:20pm UTC](https://www.ruby-forum.com/t/cgi-with-ruby/97985/1 "2006-07-11T21:20:44Z")

</div>

Hi,  
I am having some problems with Ruby CGI code. What I am trying  
to do  
is to use the Ruby WordNet Modules when working with some CGI programs.  
I  
need the CGI program to call a couple of functions defined in a  
different  
module. The CGI program seems to run fine when run from the command line  
(offline mode) but when run from a browser it does not load the WordNet  
modules.

```
   Could someone please help out with this.

   I am using wordnet 2.0 Ruby 1.8 apache2 and Suse 9

   I could include the code but there is tons of it so I could 

```

include  
whatever may be needed ( not sure what that is as of now)

harish

---

<div class="post-metadata">

**Author:** ![Harish\_TM](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/46a35a/32.png) [@Harish\_TM](https://www.ruby-forum.com/u/Harish_TM)\
**Post date:** [July 11, 2006, 10:13pm UTC](https://www.ruby-forum.com/t/cgi-with-ruby/97985/2 "2006-07-11T22:13:33Z")

</div>

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

> Hi,  
> I am having some problems with Ruby CGI code. What I am trying to do  
> is to use the Ruby WordNet Modules when working with some CGI programs. I  
> need the CGI program to call a couple of functions defined in a different  
> module. The CGI program seems to run fine when run from the command line  
> (offline mode) but when run from a browser it does not load the WordNet  
> modules.
> 
> ```
> Could someone please help out with this.
> 
> ```

What does your apache error log say?

---

<div class="post-metadata">

**Author:** ![Harish\_TM](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/46a35a/32.png) [@Harish\_TM](https://www.ruby-forum.com/u/Harish_TM)\
**Post date:** [July 11, 2006, 10:47pm UTC](https://www.ruby-forum.com/t/cgi-with-ruby/97985/3 "2006-07-11T22:47:06Z")

</div>

Hey john,  
Thanks for the reply

```
   Here is the Apache error log entry.

```

[Wed Jul 12 01:35:49 2006] [error] [client 192.168.0.34]  
/usr/lib64/ruby/site\_ruby/1.8/linguistics/en/wordnet.rb:117:in  
`wnL\exicon’:  
WordNet functions are not loaded: No such file to load – wordnet  
(NotImplementedError), referer:  
[http://192.168.0](http://192.168.0).\34/cgi-bin/TextToTermsStart.rb?name=Harish&account=Account1&theme=Theme1

Interestingly I get the same error when I ssh into the server from a  
windows  
machine (putty) and try to run the program from command line (although  
the  
program works when I run it from the server on command line) Also the  
program runs when I ssh into the server from another Linux machine. ( I  
have  
tried to access it through a browser from both windows and Linux and it  
does  
not work )

here is that error msg:

suseserver2:/srv/www/cgi-bin # ruby extract\_from\_string.rb  
/usr/lib64/ruby/site\_ruby/1.8/linguistics/en/wordnet.rb:117:in  
`wnLexicon': WordNet functions are not loaded: No such file to load -- wordnet (NotImplementedError) from /usr/lib64/ruby/site_ruby/1.8/linguistics/en/wordnet.rb:175:in `synsets’  
from {Autoloaded:  
/usr/lib64/ruby/site\_ruby/1.8/linguistics.rb}:98:in `synsets' from /usr/lib64/ruby/site_ruby/1.8/linguistics.rb:98:in `call’  
from /usr/lib64/ruby/site\_ruby/1.8/linguistics.rb:98:in  
`method_missing' from extract_from_string.rb:53:in `extractSyn’  
from extract\_from\_string.rb:87:in `extractPhrase’  
from extract\_from\_string.rb:211

I thought it had something to do with permissions and have tried  
changing  
them around. Then tried some things with the Apache config, but since  
the  
ssh is not working it looks like that is not the error. I am at a  
complete  
loss…

is there some Wordnet stuff I need to preload

Harish

---

<div class="post-metadata">

**Author:** ![Harish\_TM](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/46a35a/32.png) [@Harish\_TM](https://www.ruby-forum.com/u/Harish_TM)\
**Post date:** [July 12, 2006, 4:13am UTC](https://www.ruby-forum.com/t/cgi-with-ruby/97985/4 "2006-07-12T04:13:43Z")

</div>

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

> # exceptions if called. Requiring this file adds functions and constants to
> 
> why is it that wordnet.rb is including wordnet? its the same file right?

`require` looks for a filename, so, yeah, that may be the same file.  
Maybe you’ve got more than one wordnet.rb file in the different  
directories that Ruby’s `require` goes looking for files in?

Sorry I can’t help more. Maybe someone here can outline some of the  
tricks they use for debugging CGI scripts…

---

<div class="post-metadata">

**Author:** ![Harish\_TM](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/46a35a/32.png) [@Harish\_TM](https://www.ruby-forum.com/u/Harish_TM)\
**Post date:** [July 11, 2006, 11:14pm UTC](https://www.ruby-forum.com/t/cgi-with-ruby/97985/5 "2006-07-11T23:14:28Z")

</div>

Just to add on

was looking through the wordnet files (the ones that got installed) and  
here is a part

file wordnet.rb:

# This file contains functions for finding relations for English words.

It

# requires the Ruby-WordNet module to be installed; if it is not

installed,

# calling the functions defined by this file will raise NotImplemented

# exceptions if called. Requiring this file adds functions and constants

to  
the

# Linguistics::EN module.

module Linguistics  
module EN

```
    @hasWordnet = false
    @wnError = nil
    @wnLexicon = nil

    # Load WordNet and open the lexicon if possible, saving the 

```

error  
that  
# occurs if anything goes wrong.  
begin  
( ERROR GENERATED HERE)  
require ‘wordnet’  
@hasWordnet = true  
rescue LoadError =\> err  
@wnError = err  
end

why is it that wordnet.rb is including wordnet? its the same file right?

Harish
