Tom Christiansen's classic document "Csh Programming Considered Harmful" explains that this cannot be done in Csh at all. You need to invoke the Bourne Shell something like: set ALTERNATIVES_JAVAC_LINK=`/bin/sh -c 'realpath /etc/alternatives/javac 2>/dev/null'`