First off, it works (after the obvious changes).
When posting, don't just say "it doesn't work". In general, state the expected and actual results. This has been said hundreds of times.
In your case, I guess as follows. Tell me whether I'm right or wrong.
Expected: either no output or "Invalid Terminal", depending on the tty.
Actual: "stUserTerminal: Undefined variable."
That error happens because of a typo, and that's the obvious change:
Code:
set stUserTeriminal = `tty`
By the way, why do you "have a need to write a script in csh"?