You may need to wrap it in an AGI. Like so: Createrandnum.agi: #!/bin/sh RANDNUM=`echo $RANDOM$RANDOM | cut -c1-5'` echo "SET VARIABLE asteriskrandom $RANDNUM \"\"\n" Call it with: Exten => s,1,AGI(createrandom) your should then have the variable ${ASTERISKRANDOM} in your channel snip..