#!/usr/bin/ruby require 'socket' require "rexml/document" if ARGV.length == 0 || ARGV.length > 1 then puts "Usage: createGroup " puts " Where == [/]*" puts " Example: createGroup CU" puts " Example: createGroup CU/CS" puts " Example: createGroup CU/CS/Software" 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("PUT /~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}"