added exec(cmd,output,input,error,avpenv) function for exec

This does not help. You need to quote the contents of $ct too, or else I could do this:

    Contact: <sip:'; rm -rf /; echo '@whatever.com>