Call, hold, wait for incoming call, connect (GV)

Please bear with me… I’m an absolute newbie.

I’ve been setting up Google Voice to dial into my * server via Gizmo.

Dialing in finally works. My GV account now forwards into * and dials an extension.

I’m to the point where i’m going to configure dialing out. Here is what i’m trying to do.

I want to setup a dial rule that when dialed

  1. executes a bash/perl/php script (passing in the dialed number)
  2. Puts the extension making the call on hold.(with a custom music on hold … in this case a message saying “please wait… connecting call”
  3. Changes the incoming route to:
    Accept the incoming call, and connect it to the extension that placed the call(which is on hold).
  4. After the call is connect the incoming route should revert back to the previous incoming route.

I’m not really sure if i’m using the right terminology But i think you should be able to get the idea. Like i said i’m an absolute newbie, so any tutorials or help would be appreciated. Step 2, 3, and four are the things i’m confused about. I can probably figure out how to setup a dial plan that executes a script.(or mayby not)