#!/usr/bin/ruby require 'socket' require "rexml/document" if ARGV.length > 1 then puts "Usage: listGroups []" puts " Where == [/]*" puts puts " Example: listGroups" puts " Example: listGroups CU" puts " Example: listGroups CU/CS" exit end if ARGV.length == 1 then groupName = ARGV[0] # if groupName does not end with a "/" character, add one if !(groupName =~ /\/$/) then groupName = groupName + "/" end else groupName = "" end s = TCPSocket.new( 'infinite.local' , 80 ) s.puts("GET /~kena/addressBook/data/#{groupName}groups.xml HTTP/1.0") s.puts line = s.gets if line =~ /404/ then puts "Specified group has no sub-groups" s.close exit end #while line = s.gets #puts line #end doc = REXML::Document.new s doc.elements.each("//group") { |element| puts element.text }