Record a number

Hello,

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 script.sh with that variable:

[my-contest]
exten => _X,1,Goto(s,1)
exten => _X.,1,Goto(s,1)
exten => s,1,Answer()
exten => s,n,EAGI(/pathto/script.sh variable)

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

Thanks to all