How Do I Use the Korn Shell When My Login Shell is the C Shell?

Your login shell as set in the NIS passwd file is the C shell (/bin/csh). You wish to use the Korn shell (/bin/ksh) on OSF1 machines (alphas). When one logs into the NIS system and the C shell is specified in the shell field of the passwd file record for the user, the files .cshrc and .login in the user's home directory are executed in that order. The standard versions of these files as distributed, access a local public initialization file on the local host. These files as configured for OUHEP Alpha machines invoke, if they exist, the files $HOME/.login.XXX and $HOME/.cshrc.XXX, where XXX is the operating system name as given by the uname command. For the alphas, XXX is OSF1. In these operating system dependent init files, the commands to setup the environment and invoke the K shell may done. The Korn shell is exec'ed from the file $HOME/.login.OSF1. When the Korn shell is invoked the file $HOME/.kshrc is executed. This file should execute /etc/profile, which is the site wide initialization file for the K shell, and /etc/profile_d0setup. In this file the setup command for Fermi products is enabled, and certain Fermi products are setup. Below are edited examples of initialization files used start up the Korn shell either as a login shell or exec'ed from the C shell.

If one wishes to work in the C shell and after awhile change to the K shell one may invoke the script setksh which follows.


-------.cshrc---------------------------------------------------------------

#!/bin/csh

############################################
# template .cshrc for SunOS versions 4 & 5 #
############################################

#
# access public.cshrc file
#
if (-f /usr/local/bin/public.cshrc) then
  source /usr/local/bin/public.cshrc
else if (-f /home1/phyast/local/bin/public.cshrc) then
  source /home1/phyast/local/bin/public.cshrc
else
endif

if (-f /usr/local/bin/d0.cshrc) then
  source /usr/local/bin/d0.cshrc
endif

#
# exit if not interactive
#
if ($?prompt == 0) exit

#
# add your own commands here
#


------.login----------------------------------------------------------------

#!/bin/csh

############################################
# template .login for SunOS versions 4 & 5 #
############################################

#
# access public.login file
#
if (-f /usr/local/bin/public.login) then
  source /usr/local/bin/public.login
else if (-f /home1/phyast/local/bin/public.login) then
  source /home1/phyast/local/bin/public.login
else
  echo 'WARNING: Server unvailiable or machine type unsupported.'
  echo '         Public .login and .cshrc not accessed.'
endif

#
# add your own commands here
#

-----.login.OSF1------------------------------------------------------------

#!/bin/csh
#
# add your own commands here
#
set PATH = ($PATH $HOME/bin .)

if (-f /usr/local/bin/d0.login) then
  source /usr/local/bin/d0.login 
endif

#stty erase ^\?
set term=vt100
stty kill ^u

setenv ENV $HOME/.kshrc
setenv SHELL /bin/ksh
setenv EDITOR /bin/vi

exec ksh


-------.kshrc-----------------------------------------------------------------

# the following if block is used when exec'ing from csh to ksh
if [ "$INITED" = "" ]
then
	INITED="`date`"
	export INITED
	if [ -r /etc/profile ]
	then
	    . /etc/profile
	fi
	if [ -r /etc/profile_d0setup ]
	then
	    . /etc/profile_d0setup
	fi
        PATH=$PATH:$HOME/bin:.
fi
ENV=$HOME/.kshrc
SHELL=/bin/ksh
NODE=`uname -n | awk 'FS="." {print $1}'`
EDITOR=/usr/bin/vi
PS1='! $USER@$NODE:$PWD> '
LESS="-M"
export NODE PATH ENV SHELL EDITOR LESS PS1
#stty erase ^\?
term=vt100
stty kill ^u
set -ao vi
MORE=-c
EXINIT="set ai aw sm"


-------.profile---------------------------------------------------------------

if [ -r /etc/profile_d0setup ]
then
    . /etc/profile_d0setup
fi
PATH=$PATH:$HOME/bin:.

ENV=$HOME/.kshrc
SHELL=/bin/ksh
NODE=`uname -n | awk 'FS="." {print $1}'`
EDITOR=/usr/bin/vi
PS1='! $USER@$NODE:$PWD> '
export NODE PATH ENV SHELL EDITOR PS1
stty kill ^u
set -ao vi
EXINIT="set ai aw sm"


------setksh---------------------------------------------------------------

#!/bin/csh
#
# add your own commands here
#
#set PATH = ($PATH $HOME/bin .)
#stty erase ^\?
#set term=vt100
#stty kill ^u
setenv ENV $HOME/.kshrc
setenv SHELL /bin/ksh
setenv EDITOR /bin/vi
exec ksh 

Go To DØ at OU | OU DØ Software | OU DØ Notes


Joel Snow
Created October 31, 1995
Revised May 14, 1998