next up previous contents
Next: The Korn Shell Up: Bourne Shell Programming Previous: Trapping Errors

Dot Files

Throughout this chapter there have been mentions of the environment, such as environmental variables. For instance it was shown that the environmental variable $PROMPT allowed the user to change the appearance of his prompt during an interactive session. What if however, a user would like to have that prompt setting as the default for every session? As was mentioned earlier, the prompt setting can be placed in a file called .profile in his home directory which is executed at each login. This file is simply a script that the shell looks for at login and will execute at that time. This is where any enviromental variables should be set, such as $PROMPT and $PATH. There will likely be a file /etc/profile which will also execute during login. This is a file that the system administrator will have set as a default so that users do not need a .profile in their own directory. It also allows the system administrator to set some things like the path so that the users on the system can have access to all of the executables without having to try and figure out the paths for them. Depending on the user's level of access, the /etc/profile is often a good file to copy into his directory as a skeleton to start with. As well as enviromental settings, function definitions can also be placed in this file. This means that the list function which was described in the section on functions can be used during every session without having to be re-entered. It is always good practice to keep the functions in their own file to prevent cluttering up the .profile file. As will be seen in later chapters, the newer shells can have several of these startup files which can be quite confusing if not organized in some fashion. The functions can all be put into a file called .functions which would then be executed by the .profile file. The .function file can be executed using the source command or the . command. The .profile script would then have one of the following two lines (which are equivalent):

source .functions

or

. .functions


next up previous contents
Next: The Korn Shell Up: Bourne Shell Programming Previous: Trapping Errors

Douglas M Gingrich
Mon Apr 27 15:25:49 MDT 1998