[ Team LiB ] Previous Section Next Section

The Bourne Shell

The default shell for the Solaris Operating Environment is the Bourne shell, developed by Steve Bourne when he was at AT&T Bell Laboratories. The Bourne shell is a small shell for general-purpose use. It also provides a full-scale scripting language that is used to develop shell scripts to capture frequently performed commands and procedures. Describing how to write shell scripts is beyond the scope of this book.

graphics/new.gif

An excellent shell programming reference is UNIX Shell Programming, Revised Edition, by Stephen G. Kochan and Patrick H. Wood, Hayden Books.

Reviewing the Bourne Shell Initialization File

graphics/new.gif

The Bourne shell, when invoked as a login shell, first reads the /etc/profile file and then reads the $HOME.profile file in the user's home directory to set the user's environment. When the user logs in or starts a Bourne shell from the command line, the .profile file is read. Use this file to set the user's path and any environment variables.

Defining Bourne Shell Environment Variables

The syntax for defining an environment variable is the same for both the Bourne and Korn shells; type VARIABLE= value;export VARIABLE and press Return.


$ PS1=oak$;export PS1
$



Using Functions to Simulate Aliases for the Bourne Shell

In the Bourne shell, you can use functions to define aliases in the .profile file. The syntax for creating an alias function is shown below.


alias-name() {
     command-sequence
}

For example, if you frequently use the ftp command to send batches of files and don't want to be prompted for each file, you can create an alias for the ftp -i command to turn off interactive prompting. When you add the following line to your .profile file, ftp is started with interactive prompting turned off.


ftp() {
     ftp -i
}

graphics/new.gif

After you have made changes to a .profile file, the changes are not recognized unless you source the .profile file by typing . .profile or you log out and log in again. When you source the .profile file in a shell, the changes are recognized only in the current shell or any other shells or programs invoked from that shell.

    [ Team LiB ] Previous Section Next Section