Using a script on linux works, if you either put it in the same place the real compiler resides (usually 
/usr/bin, needs root-rights) or add the directory with the script to the 
Additional paths in the 
Toolchain executables-tab.
for 
gcc I use 
ccache-gcc with the following content:
and for 
g++ I called my script 
ccache-g++:
No environment-variables needed.
don't forget to make the scripts executable (
[/b])