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

This example does not take stderr into account.