How do I write a script so that an object rotates and follows the contours of a larger object?

First, I am newer to scripting than most of the people here that also make such claims. So basically, I would like to be able to walk around the inside circumference of a cylinder with an FPS controller. Is it possible to write a script that keeps the moving object "grounded" (perpendicular) to the geometry of the cylinder? Another example of what I'm looking for could be applied to: driving a car through a vertical loop.

I have no idea where to even begin scripting anything like this.

From the collision object passed to the OnCollisionStay event, you can access a list of contacts, and get their normals. However, there could potentially be multiple contacts, which means you'll have more than one normal. To deal with this, I would simply add the normals together, and normalize, which would give you something like this:

function OnCollisionStay(col : Collision) {
    var colNormal : Vector3 = new Vector3();
    for (var contact : ContactPoint in col.contacts) {
    	colNormal += contact.normal;
    transform.up = colNormal;