It's not working for a couple of reasons:
To run a script as an executable the first line has to tell the shell what program (i.e. which shell) should run the script, so you should start:
#!/bin/bash
or whichever shell you want.
Secondly, you can't execute this in tcsh because it uses a different syntax. You don't export environment variables, you use setenv with no equals sign. Additionally, $(command) means nothing to tcsh.