I have been banging my head over this for 2 days.  The following is to
scan a regular text file line by line using regular expressions.  it
seem to only grab the first line and not iterate through all the lines
like it should.  The "@st == True" is used for Try and Rescue for
possible failed telnet sessions, and move on to the next.

CODE:

# CE200s and COMMANDS

  def dslam_list()
    @rf.each do |line|
      if line.scan(/^N\w\w\w/)
        @dns = line.to_s.chomp()
        telnet_to_dslam(@dns, @pf)
        if @st == true
          login_to_dslam(@un, @pw)
        end
      end

      if line.scan(/^get.+/)
        @command = line.to_s.chomp()
        give_commands(@command)
      end

      if line.scan(/^$/)
        sleep (1)
        exit_commands()
      end
    end

    # close files after finsished with io
    @rf.close()
    @of.close()
  end


TEXT FILE:
The first line is the Host name that is used by telnet method.  Telnet
works fine.

N2CA
get cmsystem
get udp
get system

N7CA
get cmsystem
get udp
get system
-- 
Posted via http://www.ruby-forum.com/.