Beginner Qn - Syntax error with STDIN.gets

Can anyone tell me why I get a syntax error on the line

containing buf = STDIN.gets below?

Is there a ruby interpreter option that gives more detail on

syntax errors?

Peter Booth

require ‘net/http’

intHostname = “myhost”

intPort=18000

intPath="/home/"

uids = IO.readlines(“uids”)

currentUser = 0;

while true

        puts "How many users to add?"

        buf=""

        buf = STDIN.gets 

        

        newUsers = buf.to_i

        

        for i in 0...newUsers

                    uid = uids[currentUser]



                    headers = Hash.new

                    headers["Proxy-Remote-User"] = uid



                    h = Net::HTTP.new(intHostname,18000)

                    puts "Fetching page for user #{uid} count

#{currentUser}"

                    resp, data = h.get(intPath, headers)

                    puts "Got page for user #uid}: #{resp.message}"

                    currentUser++

        end

end

Try using $stdin.gets instead.

-austin
– Austin Ziegler, austin@halostatue.ca on 2002.10.20 at 18.31.04

Can anyone tell me why I get a syntax error on the line

containing buf = STDIN.gets below?

I can’t get parse error on that line but get other, on end' line for for’. This is since the previous line is currentUser++', which is parsed as [variable] [binary +‘] [unary +'] so a token expected to be the next is a part of some expression. end’ is not so.

Ruby does not provide unary increment/decrement operators because they
don’t fit Ruby’s programming model.

Is there a ruby interpreter option that gives more detail on

syntax errors?

Currently nothing but there’re requests for more descriptive
messages.

        buf = STDIN.gets 

This is OK but…

                    currentUser++

        end

This is troublesome.

···

In message 0F17ACE0B516D51194BC009027FC497D1AE199B2@gsny43e.ny.fw.gs.com Peter.Booth@gs.com writes:


kjana@dm4lab.to October 21, 2002
No gains without pains.