# I cant start webrick

**URL:** <https://www.ruby-forum.com/t/i-cant-start-webrick/171773>\
**Category:** Ruby\
**Created:** [July 8, 2009, 11:41pm UTC](https://www.ruby-forum.com/t/i-cant-start-webrick/171773 "2009-07-08T23:41:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![oscar-alexander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/e36b37/32.png) [@oscar-alexander](https://www.ruby-forum.com/u/oscar-alexander)\
**Post date:** [July 8, 2009, 11:41pm UTC](https://www.ruby-forum.com/t/i-cant-start-webrick/171773/1 "2009-07-08T23:41:31Z")

</div>

when i try to start webrick i get this message

./easyhtmlserver:12: syntax error, unexpected tASSOC, expecting kEND  
:Port =\> 80  
^  
./easyhtmlserver:14: syntax error, unexpected tASSOC, expecting kEND  
:Port =\> 801  
^  
./easyhtmlserver:11: warning: found = in conditional, should be ==  
./easyhtmlserver:16: syntax error, unexpected tSYMBEG, expecting ‘)’  
:DocumentRoot =\> “/home/” + $home + “/easyhtml/” + $pro  
^  
./easyhtmlserver:17: syntax error, unexpected ‘)’, expecting kEND  
./easyhtmlserver:28: syntax error, unexpected $end, expecting kEND

this is my code

#!/usr/bin/env ruby

#require the libaries  
require ‘webrick’  
include WEBrick

#make the class  
class EasyHTMLServer  
def initalize  
s = HTTPServer.new(  
if $port = 80  
:Port =\> 80  
else  
:Port =\> 801  
end  
:DocumentRoot =\> “/home/” + $home + “/easyhtml/” + $pro  
)  
end  
end

#declare the varibles  
$home = ARGV[0]  
$pro = ARGV[1]  
$port = ARGV[2]

#load the server  
EasyHTMLServer.new

---

<div class="post-metadata">

**Author:** ![oscar-alexander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/e36b37/32.png) [@oscar-alexander](https://www.ruby-forum.com/u/oscar-alexander)\
**Post date:** [July 8, 2009, 11:59pm UTC](https://www.ruby-forum.com/t/i-cant-start-webrick/171773/2 "2009-07-08T23:59:22Z")

</div>

On Wed, Jul 8, 2009 at 9:41 PM, Alex G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> :DocumentRoot => "/home/" + $home + "/easyhtml/" + $pro
> ^
> 
> ```
> 
> ./easyhtmlserver:17: syntax error, unexpected ‘)’, expecting kEND  
> ./easyhtmlserver:28: syntax error, unexpected $end, expecting kEND

This should work:

> ```
> :DocumentRoot => "/home/" + $home + "/easyhtml/" + $pro
> )
> 
> ```
> 
> end  
> end

But that code is pretty nasty to look at.

Regards,  
Ben

---

<div class="post-metadata">

**Author:** ![oscar-alexander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/e36b37/32.png) [@oscar-alexander](https://www.ruby-forum.com/u/oscar-alexander)\
**Post date:** [July 9, 2009, 12:03am UTC](https://www.ruby-forum.com/t/i-cant-start-webrick/171773/3 "2009-07-09T00:03:27Z")

</div>

On Wed, Jul 8, 2009 at 9:58 PM, Ben L.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> > ./easyhtmlserver:11: warning: found = in conditional, should be ==  
> > ./easyhtmlserver:16: syntax error, unexpected tSYMBEG, expecting ‘)’  
> > :DocumentRoot =\> “/home/” + $home + “/easyhtml/” + $pro  
> > ^  
> > ./easyhtmlserver:17: syntax error, unexpected ‘)’, expecting kEND  
> > ./easyhtmlserver:28: syntax error, unexpected $end, expecting kEND
> 
> This should work:

Sorry, ignore me. I just re-read the post and noticed the problems with  
with  
hash arguments too. Not sure how you solve this.

---

<div class="post-metadata">

**Author:** ![oscar-alexander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/e36b37/32.png) [@oscar-alexander](https://www.ruby-forum.com/u/oscar-alexander)\
**Post date:** [July 9, 2009, 12:26am UTC](https://www.ruby-forum.com/t/i-cant-start-webrick/171773/4 "2009-07-09T00:26:15Z")

</div>

spox wrote:

> s = HTTPServer.new(:Port =\> $port == 80 ? 80 : 801, :DocumentRoot =\> ‘etc…’)

Yikes!

Are people really so adverse to creating simple methods that describe  
intent? (They also make testing easier 🙂 )

# Pick a name that makes sense if this is not a good one …

def default\_port default=801  
$port == 80 ? 80 : default  
end

s = HTTPServer.new :Port =\> default\_port, :DocumentRoot =\> ‘etc…’

–  
James B.

[www.jamesbritt.com](http://www.jamesbritt.com) - Playing with Better Toys  
[www.ruby-doc.org](http://www.ruby-doc.org) - Ruby Help & Documentation  
[www.rubystuff.com](http://www.rubystuff.com) - The Ruby Store for Ruby Stuff  
[www.neurogami.com](http://www.neurogami.com) - Smart application development

---

<div class="post-metadata">

**Author:** ![oscar-alexander](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/e36b37/32.png) [@oscar-alexander](https://www.ruby-forum.com/u/oscar-alexander)\
**Post date:** [July 9, 2009, 12:11am UTC](https://www.ruby-forum.com/t/i-cant-start-webrick/171773/5 "2009-07-09T00:11:38Z")

</div>

On Wednesday 08 July 2009 14:41:38 Alex G. wrote:

> this is my code  
> s = HTTPServer.new(  
> :DocumentRoot =\> “/home/” + $home + “/easyhtml/” + $pro  
> #load the server  
> EasyHTMLServer.new

s = HTTPServer.new(:Port =\> $port == 80 ? 80 : 801, :DocumentRoot =\>  
‘etc…’)
