4

I'm running into this syntax error with the below code and I can't figure out why ruby is complaining about it.

  def user_list
  server = Lumberg::Whm::Server.new(
  host: "localhost",
  hash: IO.read("/root/.accesshash")
)

results = server.account.list
accounts = result[:params][:acct].map {|a| a["user"] }

 end
end

Syntax error is as follows:

# bundle exec bin/userscan 
bin/userscan:3:in `require': /usr/src/userscan/lib/userscan.rb:131: syntax error, unexpected ':', expecting ')' (SyntaxError)
  host: "localhost",
       ^
/usr/src/userscan/lib/userscan.rb:131: syntax error, unexpected ',', expecting kEND
/usr/src/userscan/lib/userscan.rb:133: syntax error, unexpected ')', expecting kEND
    from bin/userscan:3

From what I know, the part it's complaining about -should- be okay. Obviously, the semi-colon is actually supposed to be there and the parenthesis should encompass the entirety of the two lines. I've played around with it a bit, but I just keep making it worse rather than better.

Any assistance with what I'm messing up here would be appreciated.

Striketh
  • 559
  • 1
  • 5
  • 17

1 Answers1

5

the syntax host: ".." is new to ruby 1.9. If you are using ruby 1.8, you must use the old syntax:

server = Lumberg::Whm::Server.new(
    :host => "localhost",
    :hash => IO.read("/root/.accesshash") )
Torsten Robitzki
  • 3,041
  • 1
  • 21
  • 35
  • That was it. I'm on a ruby 1.8 server and didn't realize the difference between 1.8 and 1.9 in that regard. Thanks for your assistance. – Striketh Nov 04 '13 at 21:13
  • I'm running 1.9.3 according to `ruby --version` but I still see the same syntax error and have to fix it by using the old syntax. Is there a reason for that? – The Unknown Dev Nov 05 '15 at 18:28