TexSan,
in the simplest case you even don't have to setup anything to collect cdr data. since you have g3r, you have two options: either use a data module (74xx, 84xx or z3ax series) or tn799 circuit pack to store cdr over tcp/ip. in first case it's as simple as it gets: add a data module, connect it to a pc via straight serial cable, ch sys cdr and set your cdr endpoint to this module extension. then run some serial terminal emulator like hyperterminal, teraterm, tutty or whatever and collect your cdr data. it will be in the form of text strings that system will output through the data module every time a call is finished.
if you do have tn799 board and want to use software-only solution, fine. go
there and download avaya reliable data transport tool. install it on a pc, start it, then add this pc's ip address as a node-name (using 'ch node-name ip' command), then do a 'change ip-services' and assign a service type 'CDR1' to this node with port 9100. don't forget to tick 'reliable' field if you want this transport to be reliable -- i.e. if the connection is broken, system will know it immediately.
then in the 'ch sys cdr' set the primary output to 'CDR1' and have fun.
nothing complex, really, and it will save you a lot of time on developing your script.