DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Sample shell startup files

The Bourne shell .profile

The Bourne shell (sh) reads a single file in your home directory, the .profile. A typical Bourne shell .profile might look something like this:

1  :
2  #	@(#) profile 23.1 91/04/03
3  #
4  # .profile	-- Commands executed by a login Bourne shell
5  #
6  # Copyright (c) 1985-1995 The Santa Cruz Operation, Inc.
7  # All rights reserved.
8  #
9  # This Module contains Proprietary Information of the Santa Cruz
10 # Operation, Inc., and should be treated as Confidential.
11 #

12 PATH=$PATH:$HOME/bin:. # set command search path 13 MAIL=/usr/spool/mail/`logname` # mailbox location 14 export PATH MAIL 15 # use default system file creation mask 16 eval `tset -m ansi:ansi -m :\?${TERM:-ansi} -r -s -Q`


line 1
Contains a single colon that says ``execute this script as a Bourne shell script.'' This is a convention for scripts written in Bourne shell, so C shells know to start a new sh to run the Bourne shell scripts.

(C shells need to start Bourne shells to run Bourne shell scripts because they do not understand the Bourne shell language. The Korn shell, however, is compatible with the Bourne shell, so you can use most Bourne shell scripts in the Korn shell without a problem.)


lines 2-11
Contain comments. Each line that starts with a number sign (#) is a comment. The shell ignores these lines. In this case, lines 2-11 contain copyright information.

line 12
Sets the path. It says, ``set the path equal to the current path, plus the bin in the home directory, plus the current directory (.).'' Setting the path to the existing path presumes there is a system-wide /etc/profile that sets up a path definition for all users. The path definition in /etc/profile would contain the usual command directories, such as /bin and /usr/bin.

line 13
Tells the shell where to find mail. The `logname` in backquotes tells the shell to substitute the output of the command logname(C), which returns a user's login name. Because `logname` is used instead of a particular login name, this script works for any user.

line 14
Tells the shell to export the PATH and MAIL settings to all its subshells. This guarantees that if you type sh to start a new Bourne shell, the new Bourne shell has the same path definition and mail setup as your login Bourne shell.

line 15
Contains a comment, like lines 2-11. This comment tells us that login Bourne shells use the default system file creation mask, which is set in /etc/profile. This explains why there is no umask setting in this .profile.

line 16
Sets up the terminal type, using the tset(C) (terminal setup) command. tset sets your terminal type, as well as the erase and kill characters for your terminal.

This tset command says ``check if this serial line is mapped to ansi in the /etc/ttytype file; if it is, set the terminal type to ansi. Otherwise, prompt the user with TERM:ansi.'' The -r option prints the terminal type on the screen, -s exports the terminal type to any subshells, and -Q suppresses the Erase set to ..., Kill set to ... messages that tset would otherwise show. The tset command is enclosed in backquotes and preceded by the shell command eval to guarantee that all necessary substitutions are made within the tset command before it is evaluated by the shell.


Next topic: The Korn shell .profile and .kshrc
Previous topic: Sample shell startup files

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003