Determine the source of login

Hi,

I log into Sun/Hp-Ux boxes from different environments, sometimes OpenSuse and sometimes windows. This script may be of use to people who want find themselves doing the same thing. My Windows ip address is assigned dynamically, so this script gets the new address and sets the DISPLAY variable to match. It also determines whether the login came from windows or some other location.

WIN_HOST="your windows os host name"
HOSTNAME=`hostname`
 
if  `uname -s` = "SunOS" ];then
NS_LOOKUP="/usr/sbin/nslookup"
LOGIN_SOURCE=`last ${USER} | head -n 1 | grep -c ${WIN_HOST}`
else
NS_LOOKUP="nslookup"
LOGIN_SOURCE=`last -R ${USER} | head -n 1 | grep -c ${WIN_HOST}`
 
fi
 
PROFILE="profiles"
 
if  "$LOGIN_SOURCE" = "1" ]; then
    IP_ADD=`${NS_LOOKUP} ${WIN_HOST} | tail -2 | sed -e 's/Address: //;/^$/d'`
    export DISPLAY="${IP_ADD}:0.0"
fi
 
if  "$HOSTNAME" = 'your sun server name' ];
then
  source ${HOME}/${PROFILE}/your_server.profile
fi
 
if  $HOSTNAME = 'your other sun server name' ]
then
  source ${HOME}/${PROFILE}/your_other_server.profile
fi
 
if  $HOSTNAME = 'your HP-UX server' ]
then
  stty kill '^K'
  set $TERM dtterm
  source ${HOME}/${PROFILE}/hp_ux_server.profile
fi
 
 
echo "Have a lot of fun..."

/jlar