#!/usr/bin/ruby require 'socket' require "rexml/document" if ARGV.length == 0 || ARGV.length > 1 then puts "Usage: removeGroup " puts " Where == [/]*" puts puts " Example: removeGroup CU" puts " Example: removeGroup CU/CS" puts " Example: removeGroup CU/CS/Software" puts puts " Note: specified group must be empty" exit end groupName = ARGV[0] # if groupName does not end with a "/" character, add one if !(groupName =~ /\/$/) then groupName = groupName + "/" end s = TCPSocket.new( 'infinite.local' , 80 ) s.puts("DELETE /~kena/addressBook/data/#{groupName} HTTP/1.0") s.puts doc = REXML::Document.new s status = doc.root.elements["//status"] reason = doc.root.elements["//reason"] if !(defined?(status) && defined?(reason)) then puts "Received Invalid Response from Server" exit end if status.text == "success" then print("Succeeded: ") else print("Failed: ") end puts "#{reason.text}"