Record a number


I need to save a number (when in a call, dial and save the dialled code number) in to a variable.

I need that code number in a variable to run a with that variable:

exten => _X,1,Goto(s,1)
exten => _X.,1,Goto(s,1)
exten => s,1,Answer()
exten => s,n,EAGI(/pathto/ variable)

I need to get that variable from my real time call…

Thanks to all