Code:
//get world space positions of the CVs
vector $pos1 = `xform -q -t -ws curve1.cv[0]`;
vector $pos2 = `xform -q -t -ws curve1.cv[1]`;
vector $newVec = $pos2 - $pos1;
//calculate rotation
$rotation = `angleBetween -euler -v1 0.0 1.0 0.0 -v2 ($newVec.x) ($newVec.y) ($newVec.z)`;
//set rotation of nurbs circle
nurbsCircle1.rotateX = $rotation[0];
nurbsCircle1.rotateY = $rotation[1];
nurbsCircle1.rotateZ = $rotation[2];
It seems to work okay, aside from a weird error