Listing 7. Manipulating xauth to Display X Programs on the Private Network

#/bin/csh
#
# /etc/profile.d/pbsX.csh
#
# If PBS_ENVIRONMENT is set to PBS_INTERACTIVE and
# DISPLAY is set, mangle DISPLAY to point at the ssh
# pseudo-display on the front end's private interface
# and modify xauth accordingly.
if ( $?DISPLAY && $?PBS_ENVIRONMENT ) then
  if ( $PBS_ENVIRONMENT == "PBS_INTERACTIVE" ) then
    setenv OLDDISPLAY `echo $DISPLAY | sed 's/\.0//'`
    setenv AUTHKEY `xauth list | grep $OLDDISPLAY | sed "s/oscbw[0-9]*.osc.edu/node00.cluster.osc.edu/" | head -1`
    setenv DISPLAY `echo $DISPLAY | sed 's/oscbw01/node00.cluster/'`
    xauth add $AUTHKEY
  endif
endif