HEPiX Shells Scripts - Anatomy

This page describes the anatomy of the HEPiX Shells Scripts, i.e. what runs behind the scene when running a shell, after a telnet, an rlogin, an rsh, an xterm, an su, a ksu, and in really many other contexts


Shell Wrappers

Normal behaviour

When a shell starts, it usually executes some system level files residing under /etc. These files usually provide a system level default set of environment variables, perform some actions.

Unfortunately all the shells allow this possibility (sh, ksh, csh) and therefore, the only to give users a "system" default is to hardcode in their user level shell files, few lines which enable HEPiX.

HEPiX Behaviour

The shell system level files under /etc are backed up under a name oldname.std. If there is no such a file, a 0 size file with the extension .std is created.

Then the system files are replaced by the HEPiX wrappers. The latter are responsible to determine wethere the user should run the vendor files (with the extension .std) or to start the HEPiX shell scripts in the HEPiX shell location path (default is /usr/local/lib/hepix/shells/hep).

For more information consult the files description.


Central Files

The central files are responsible to start HEPiX if scripts are installed in weak mode (i.e. the wrappers are not installed).

They can be sourced from the user dot files.

For more information consult the files description.


HEPiX Shell Scripts

In this section we describe some special features of the environment, login and interactive parts of the scripts as far as the dynamic behaviour is concerned

Environment settings

Environment which is always executed

HEP files: Environment part

check for login permissions (/etc/nologin)
if ( ! HEP_ENV ) {
   initialisation
   setting of environment variables via sys.conf.[c]sh
   other environment variables are tuned (PATH, ENV, GROUP, etc.)
   set env HEP_ENV not to recalculate the environment for each interactive
   shell
}
Load aliases in all cases (useful for BATCH)
if ( Connected to terminal ) {
   setting the prompt
   sourcing the interactive parts
   enable the advance features
   setting of ENVIRONMENT to INTERACTIVE
}
else {
   setting of ENVIRONMENT to BATCH if not defined
}
If there exists a /etc/nologin file the user cannot login and he gets a message about the reason (standard mechanism on many systems). For improving the execution effiency an environment variable HEP_ENV is defined. If this variable is set then the environment is assumed to be partly set and in subshells only the interactive part is executed again.

To manage a change of a shell to the ksh or bash the ENV variable is set to /etc/zshenv.

This environment part includes also the setting of the following environment variables which the user can use in his own scripts:

Login part

HEP files - Login part of the session

check for login permissions (/etc/nologin)
if ( Connected to a terminal ) {
   set env ENVIRONMENT to LOGIN
}
else {
   set env ENVIRONMENT to BATCH if not defined
}
if ( ! BATCH ) {
   support DESY xrlogin
   terminal type check
   set terminal characteristics
   check for mails
   source local adaptations (Site level)
}
Because in most cases the csh, ksh and bash do not have any global configuration files which are always executed the actions described before are performed in addition if necessary.

In order to avoid tty related commands or commands requiring tty input a check for batch mode takes place. In the Bourne-like shells you are in interactive mode if a file descriptor is associated with a terminal device, in the C-like shells you are in interactive mode if the prompt is set. Under some circumstances, e.g. if you login via a terminal server then it is possible that you get an improper terminal type (eg. dumb, network). An optional file /usr/local/lib/hepix/termset.[c]sh changes such types to a terminal type which is described in /usr/lib/terminfo or /etc/termcap.

Afterwards some settings of the terminal characteristics will be made (for instance defining the erase key dependent on the RUBOUT variable).

Other stty settings cover the interrupt key (Ctrl C) and the suspend key (Ctrl Z). After the execution of the login file for local adaptations (/usr/local/lib/hepix/login.[c]sh) a check on incoming mail is done.

Interactive part

The last part is used for settings of the interactive environment.

The prompt acts as a reminder of where you logged into and shows your current directory. Where possible the tilde notation for home directories is used. In all cases the superuser is indicated by a hash sign ("#") in his prompt.

A small set of common aliases or functions is defined. You can use these aliases in all shells and systems in the same way.

For csh and tcsh there are additional system dependencies. Also the names of the scripts may differ not mentioned in the table. On some UNIX systems in csh global initialisation files are executed while the default action in tcsh on some systems is not to execute global scripts (e.g. IRIX).


Arnaud Taddei, 8-Jul-1996