Revisting IVR -> Script

CallerID Variables are documented here Home - Asterisk Documentation

So you would want something like ${CALLERID(num)} or ${CALLERID(all)}

AFAIK $IVROPTION is not a variable, but could be I am wrong.

You have two options:

First. Point each IVR option to a custom destination which will execute a custom dilaplan and then set the return to your final destination.

Second. Do something like as mentioned here:

In the override file:

[ivr-3]
exten => 1,1,Gosub(ivr-track,s,1(${EXTEN}))
exten => 2,1,Gosub(ivr-track,s,1(${EXTEN}))
exten => 3,1,Gosub(ivr-track,s,1(${EXTEN}))
exten => 4,1,Gosub(ivr-track,s,1(${EXTEN}))

And in extensions_custom.conf

[ivr-track]
exten => s,1,Noop(Entering context in extensions_custom.conf to execute custom dialplan)
exten => s,n,TrySystem(/home/asterisk/my_script.sh ${CALLERID(num)} ${ARG1})
exten => s,n,Set(__ivrreturn=0)
exten => s,n,Return()

Hope that helps