Oracle's .cshrc Oracle's .profile Oracle's .profile_references Oracle's .profile_paths Oracle's .profile_READ_ME

Appendix A

This appendix lists the source code from several start up files to show the layout and interconnections between the files. Use these pages as a guide when planning your own systems. The first file is the .cshrc file from the Oracle shared account, showing how to create user specific environments from the same account set-up.

Oracle's .cshrc file

# begin ora .cshrc $Revision: 6.113 $ --------------dont delete this line---
limit   coredumpsize    0k
set filec
###############################
# Fixed Stuff - For everybody #
###############################
setenv COMPANY acme
setenv DEVELOPMENT_SERVER devsrv1
setenv ORACLE_VERSION 7.1.6
setenv THISHOST `/usr/bin/uname -n`
setemv PROJECT $CO/$THISHOST/unix/cen
setenv ORACLE_BASE /$PROJECT/oracle_base
setenv ORACLE_HOME /$ORACLE_BASE/product/$ORACLE_VERSION
setenv ORATAB /var/opt/oracle/oratab
setenv TNSNAMES /var/opt/oracle/tnsnames.ora
setenv LD_LIBRARY_PATH /usr/openwin/lib:$ORACLE_HOME/lib
setenv MANPATH "/usr/bin/man:/usr/share/man:/usr/openwin/man:"
setenv MANPATH "${MANPATH}/usr/openwin/share/man:/usr/man:"
setenv MANPATH "${MANPATH}/$PROJECT/NeWSprint/man"
setenv OPENWINHOME /usr/openwin
setenv NEWSPRINT_HOME /$PROJECT/NeWSprint
setenv DFRAG_HOME /$PROJECT/DFrag
setenv TK2DEV xsun
setenv TERM sun
setenv EDITOR vi
setenv REAL_PRINTER printer_4
setenv PRINTER printer_4
setenv LPDEST printer_4
setenv ME `tty |cut -c6-`
#####################################
# Put development unique items here #
#####################################
if ( "$THISHOST" == "$DEVELOPMENT_SERVER" ) then
	setenv REAL_PRINTER printer_4
endif
##########################
# Setup the path strings #
##########################
set path	=	(.				\
			./bin			\
			/usr/bin			\
			/usr/sbin			\
			/usr/ucb			\
			/etc			\
			/usr/etc			\
			/$PROJECT/NeWSprint/bin	\
			/usr/openwin/bin		\
			/usr/ccs/bin		\
			$ORACLE_HOME/bin)
######################################################
# Check for Terminal Access  - if yes, setup aliases #
######################################################
set answer = `tty` >& /dev/null
set answer = $status
if ($answer == 0) then	# The rest of this file is inside the IF  #
###########################################################################
# If its Robert Bloggs from ukf151 				    	  #
# and set up environment to remote display oracles mail messages at home  #
###########################################################################
set rob1 = `finger | grep " $ME " | grep ukf151 | wc -l | cut -c1-8`
set rob2 = `finger | grep " $ME " | grep "254.254.2.3" | wc -l | cut -c1-8`
set rob = `expr $rob1 + $rob2`
if ( $rob >= 1 ) then
	setenv DISPLAY 254.254.254.254:0.0
	setenv PRINTER $REAL_PRINTER
endif
###########################################################################
# If its Richard Reepe from ukf068  - then set my erase char to CONTROL-H #
# and set up environment to remote display oracles mail messages at home  #
###########################################################################
set richard1 = `finger | grep " $ME " | grep ukf068 | wc -l | cut -c1-8`
set richard2 = `finger | grep " $ME " | grep "254.254.3.2" | wc -l | cut -c1-8`
set richard = `expr $richard1 + $richard2`
if ( $richard >= 1 ) then
	setenv DISPLAY 254.254.254.254:0.0
	setenv PRINTER $REAL_PRINTER
	stty erase ^H
	set ws = "-Ws 585 281"	# Window Size Params for Oracle Mailtools
	if ( "$THISHOST" == "green" )  set opt = "-Wp 0  4   	\
			$ws -WP 5 320 -Wl green  -WL green  \
			-Wf 000 000 000 -Wb 255 255 000"
	if ( "$THISHOST" == "blue" )   set opt = "-Wp 10 24   	\
			$ws -WP 5 390 -Wl blue   -WL blue   \
			-Wf 000 000 000 -Wb 100 255 255"
	if ( "$THISHOST" == "red" )  set opt = "-Wp 20 44   	\
			$ws -WP 5 460 -Wl red  -WL red  \
			-Wf 000 000 000 -Wb 000 230 255"
	if ( "$THISHOST" == "yellow0" ) set opt = "-Wp 30 64   	\
			$ws -WP 5 530 -Wl yellow -WL yellow \
			-Wf 000 000 000 -Wb 000 180 255"
	if ( "$THISHOST" == "orange" )  set opt = "-Wp 40 84   	\
			$ws -WP 5 600 -Wl orange  -WL orange  \
			-Wf 255 255 255 -Wb 000 120 255"
	if ( "$THISHOST" == "pink" )  set opt = "-Wp 50 104  	\
			$ws -WP 5 670 -Wl pink  -WL pink  \
			-Wf 255 255 255 -Wb 000 000 210"
	if ( "$THISHOST" == "black" )   set opt = "-Wp 60 124  	\
			$ws -WP 5 740 -Wl black   -WL black   \
			-Wf 255 255 255 -Wb 000 000 130"
	alias omail "toolwait mailtool -Wi $opt"
endif
###########################################################################
# If its Claire Harris from ukf153 - then set my erase char to CONTROL-H #
# and set my printer and display environment variables			     #
###########################################################################
set claire1 = `finger | grep " $ME " | grep ukf153 | wc -l | cut -c1-8`
set claire2 = `finger | grep " $ME " | grep "254.254.2.3" | wc -l | cut -c1-8`
set claire = `expr $claire1 + $claire2`
if ( $claire >= 1 ) then
	setenv DISPLAY 254.254.254.254:0.0
	setenv PRINTER $REAL_PRINTER
	stty erase 
endif
###########################################################################
# If its Andrew Clark from fus122 or fus123                               #
# and set up environment to remote display                                #
###########################################################################
set drew1 = `finger | grep " $ME " | grep fus122 | wc -l | cut -c1-8`
set drew2 = `finger | grep " $ME " | grep "254.254.254.254" | wc -l | cut -c1-8`
set drew = `expr $drew1 + $drew2`
if ( $drew >= 1 ) then
	setenv DISPLAY fus122.pd9.$CO.com:0.0
	setenv PRINTER pr1953
	stty erase 
endif
##############################
# now some alias definitions #
##############################
alias	a		alias
alias	b		ls -l /$CO/thishost/u/oracle_data_1/BACKUPS
alias	d		'df -k | grep ora'
alias	h		history
alias	l		ls -lisa
alias	dba		~/scripts/sql_dba
alias	s		cd $ORACLE_BASE/scripts
alias	S		cd $ORACLE_BASE/SQL
alias	doc		cd $ORACLE_BASE/documentation
alias	dbs		cd $ORACLE_HOME/dbs
alias	cron		cd $ORACLE_BASE/cron
alias	logs		~/scripts/read_logs
alias	olds		~/scripts/read_old_logs
alias	del		~/scripts/delete_script
alias	distribute	~/scripts/distribute_file
alias	disdir		~/scripts/distribute_directory
alias	sql		~/scripts/sql_plus
alias	access		~/scripts/create_database_locations
alias	apply		~/scripts/data_ccar
alias	report		~/scripts/report
alias	unlock		~/scripts/unlock_process
alias	process		~/scripts/completed_process
alias	space		~/scripts/db_space
alias	whos_using	~/scripts/whos_using
alias	wots_up		~/scripts/wots_up
alias	help		~/scripts/help
alias	how		~/scripts/how
alias	fun		~/scripts/functions
alias	C		'~/scripts/sccs_command C'
alias	D		'~/scripts/sccs_command D'
alias	E		'~/scripts/sccs_command E'
alias	G		'~/scripts/sccs_command G'
alias	P		'~/scripts/sccs_command P'
alias	R		'~/scripts/sccs_command R'
alias	menu		~/scripts/script_menu
alias	resource	~/scripts/resource_maintenance
alias	pdcr		~/scripts/create_pdcr_file
alias	product		'~/scripts/product;source /tmp/p_tmp'
alias	list		'nl -ba -s}'
alias	print		'~/scripts/print'
alias	xprint		'~/scripts/xprint'
alias	land		'~/scripts/land'
alias	install		'shelltool -B Offset_x -Wl "Ora Inst" -WL "Ora Inst" &'
alias	em		'emacs -bg snow1 &'
alias	oracle-help	'cd $ORACLE_HOME; orainst/oradocm &'
endif		# Closing line from terminal test #
################################
# End of Terminal Access Setup #
################################

Next is the main .profile which is much shorter because it is now in several pieces for ease of management. This is followed by the other related .profiles. The functions are all grouped together in the section dedicated to functions.

Oracle's .profile

################################################################
# ORACLE's .profile (c) R. H. Reepe 8th March 1995 Version 3.0 #
################################################################
# 960419 RHR Restructured into separate .profiles
################################################################
# Add Database Name Reference Strings                          #
################################################################
. $HOME/.profile_references
################################################################
# General Setup Information                                    #
################################################################
export DEVELOPMENT_SERVER="ukf123"
export RECON_MASTER="masterdb"
export RECON_SERVER="ukf124"
export EDITOR=vi
export UNIX=`/usr/bin/uname -r | cut -c1-1`
export THISHOST=`/usr/bin/uname -n`
export ORACLE_VERSION=7.1.6
export COMPANY=acme
################################################################
# Remaining General Profiles                                   #
################################################################
. $HOME/.profile_paths
. $HOME/.profile_oracle
. $HOME/.profile_copyres
. $HOME/.profile_function
################################################################
# Count of Available Oracle Products (Versions of Oracle)      #
################################################################
export PRODUCT_COUNT=`ls -1 $ORACLE_BASE/product | grep -c "."`

Oracle's .profile_references


############################################################################
# .profile_references (c) R. H. Reepe 17th May 1995 Version 1.0            #
############################################################################
# This PROFILE contains mapping lists for servers and databases and is     #
# used by several scripts to create and contact remote databases. The      #
# format of this file is vital to Database Administration Integrity and    #
# should be strictly adhered to for guaranteed continued operation. If     #
# not set up correctly, Global Database Access will cease to work.         #
# The data from this file is used primarily to populate the Master table   #
# DATABASE_REFERENCES in all Master Databases. This is then copied to all  #
# Production Databases as part of the copy_resources_db process for all    #
# STATIC Data. Entries in DATABASE_LOCATIONS are based on the data stored  #
# in DATABASE_REFERENCES as transformed and assembled by APPL_ADMIN        #
# Procedures and Functions, and APPL_UTILITIES Procedures and Functions.   #
#                                                                          #
# REFERENCE_DATABASE = a list of single Words describing the DATABASE Type #
#                      used to populate the DATABASE_LOCATIONS table for   #
#                      Global Estimate Access (GEA).                       #
#                                                                          #
# REFERENCE_DBSERVER = a list of Database Host SERVERS which support a     #
#                      Production Database. Used to populate the           #
#                      DATABASE_LOCATIONS table. One of the KEY fields in  #
#                      the DATABASE_REFERENCES table.                      #
#                                                                          #
# REFERENCE_IPDOMAIN = a list of TCP/IP DOMAIN Names where Servers are     #
#                      located on the Intranet. Used for file transfers.   #
#                                                                          #
# REFERENCE_LOCATION = a list of LOCATION mnemonics to uniquely identify   #
#                      a Server Site. Used to populate DATABASE_LOCATIONS. #
#                                                                          #
# REFERENCE_DBPREFIX = a list of 2 character strings for use by Oracle to  #
#		       create the DATABASE_PREFIX strings used for GDA     #
#		       HOME_DATABASE Indicators within the user APPL.      #
#                                                                          #
# REFERENCE_DBSERIES = a list of 1 character numeric database SERIES flags #
#		       used to generate the last character of the database #
#		       prefix string used for GDA HOME_DATABASE Indicators #
#		       within APPL.                                        #
#                                                                          #
# REFERENCE_DB_SIZES = a list of integer Generic_Database_Unit SIZE        #
#		       parameters used by GENERATE_DB when setting the     #
#		       sizes of database TABLESPACES. This value should    #
#		       be increased by 50% for a server who's database     #
#		       has flagged a space shortage.                       #
#                                                                          #
# REFERENCE__COUNTRY = a list of COUNTRY Names to locate the APPL          #
#		       Database with its $CO Operation. Used to populate   #
#		       the DESCRIPTION Field of DATABASE_LOCATIONS         #
#                                                                          #
# REFERENCE_BUILDING = a list of $CO BUILDING Names to locate the APPL     #
#		       Database with its $CO Operation. Used to populate   #
#	               the DESCRIPTION Field of DATABASE_LOCATIONS	   #
#                                                                          #
# This file is split up into sections for each Country. The Variables are  #
# in lower case and are prefixed by a APPL Country Code and identified by  #
# a single letter code for usage:				           #
#                                                                          #
# MapChar   ListName            Domain		Description	           #
# -------   ------------------- -----------   ------------------------     #
# h = REFERENCES_DBSERVER       (Host)         Host IP Alias Name          #
# d = REFERENCES_IPDOMAIN       (Domain)       Host Domain Name            #
# l = REFERENCES_LOCATION       (Location)     Database_SID (Chars 1-4)    #
# f = REFERENCES_DBPREFIX       (preFix)       Database_ID (Chars 1&2) #
# s = REFERENCES_DBSERIES       (Series)       Database_ID (Char 3)        #
# b = REFERENCES_BUILDING       (Building)     DATABASE_LOCATIONS (Descr)  #
# c = REFERENCES__COUNTRY       (Country)      DATABASE_LOCATIONS (Descr)  #
# z = REFERENCES_DB_SIZES       (siZe)         Generic Database Unit Mb    #
#     REFERENCES_DATABASE       (TYPE)         generate_db TYPES	    #
#                                                                          #
# When creating new Country sections follow this format and place Country  #
# in its alphabetic location in the list. Then at the end of the file add  #
# the variable names into the lists which create the exported REFERENCE    #
# variables (in the correct position or internal mapping will be wrong).   #
#                                                                          #
# The IP aliases must = HOSTNAME from `uname -n`                           #
#                                                                          #
# All names in these lists must be delimited by SPACE's Only. No TAB's are #
# allowed in this format. Server Names can be any length but must agree    #
# with the IP Alias for the server. Location Names must be 4 characters    #
# long and be unique globally. Flag Names must be 2 characters long and be #
# unique globally.                                                         #
############################################################################
# 960415 RHR Genesis
# 960515 RHR Added DB_SIZES for GENERATE_DB usage
# 960618 RHR Added DBSERIES for GDA Database_ID usage
# 960619 RHR Re-Ordered Variables for ease of maintenance
# 960731 RHR Added Domains
######################
# EXPORTED VARIABLES #
######################
export REFERENCE_DATABASE
export REFERENCE_DBSERVER
export REFERENCE_IPDOMAIN
export REFERENCE_LOCATION
export REFERENCE_DBPREFIX
export REFERENCE_DBSERIES
export REFERENCE_BUILDING
export REFERENCE__COUNTRY
export REFERENCE_DB_SIZES
##################
# Deuschland     #
##################
de_h_map="duf021             "
de_d_map="black.$CO.com      "
de_l_map="aok_               "
de_f_map="da                 "
de_s_map="3                  "
de_b_map="Black_House        "
de_c_map="Germany            "
de_z_map="11                 "
##################
# Espanya        #
##################
es_h_map="esf011             "
es_d_map="purple.$CO.com     "
es_l_map="dop_               "
es_f_map="es                 "
es_s_map="3                  "
es_b_map="Purple_house       "
es_c_map="Spain              "
es_z_map="11                 "
##################
# Gt Britain     #
##################
gb_h_map="ukf123              ukf124              ukf125              ukf171              ukf212"
gb_d_map="blue.$CO.com        green.$CO.com       red.$CO.com         yellow.$CO.com      white.$CO.com"
gb_l_map="tes_                dev_                aor_                boy_                cow_"
gb_f_map="ts                  dv                  gb                  du                  jw"
gb_s_map="3                   3                   3                   3                   3"
gb_b_map="Blue_House          Green_House         Red_House           Yellow_House        White_House"
gb_c_map="Britain             Britain             Britain             Britain             Britain"
gb_z_map="11                  11                  11                  11                  11"
##################
# United States  #
##################
us_h_map="cad200             cad295              "
us_d_map="abc.$CO.com        bbd.$CO.com         "
us_l_map="boa_               cob_                "
us_f_map="us                 mx                  "
us_s_map="3                  3                   "
us_b_map="Building_Nine      Building_Seven      "
us_c_map="America            America             "
us_z_map="40                 30                  "
##################
# Global Mapping #
##################
REFERENCE_DATABASE="Administration Development Evaluation Guidence Master Production Test"
REFERENCE_DBSERVER="$de_h_map $es_h_map $gb_h_map $us_h_map "
REFERENCE_IPDOMAIN="$de_d_map $es_d_map $gb_d_map $us_d_map "
REFERENCE_LOCATION="$de_l_map $es_l_map $gb_l_map $us_l_map "
REFERENCE_DBPREFIX="$de_f_map $es_f_map $gb_f_map $us_f_map "
REFERENCE_DBSERIES="$de_s_map $es_s_map $gb_s_map $us_s_map "
REFERENCE_BUILDING="$de_b_map $es_b_map $gb_b_map $us_b_map "
REFERENCE__COUNTRY="$de_c_map $es_c_map $gb_c_map $us_c_map "
REFERENCE_DB_SIZES="$de_z_map $es_z_map $gb_z_map $us_z_map "

Oracle's .profile_paths


################################################################
# .profile_paths (c) R. H. Reepe 19th April 1996 Version 1.0   #
################################################################
# 960419 RHR Genesis
################################################################
# Selected Short Paths for  SQL SCRIPT Use                     #
################################################################
export PROJECT=/$CO/$THISHOST/unix/cen
export ORACLE_BASE=$PROJECT/oracle_base
export ORACLE_HOME=$ORACLE_BASE/product/$ORACLE_VERSION
export ORACLE_BIN=$ORACLE_HOME/bin
export ORACLE_SQL=$ORACLE_BASE/SQL
export ORACLE_SCRIPTS=$ORACLE_BASE/scripts
export ORACLE_CRON=$ORACLE_BASE/cron
export ORACLE_LOG=$ORACLE_BASE/logfiles
export ORACLE_LOD=$ORACLE_BASE/loaders
export ORACLE_PAC=$ORACLE_SQL/PACKAGES
export ORACLE_PRO=$ORACLE_SQL/PROCEDURES
export ORACLE_FUN=$ORACLE_SQL/FUNCTIONS
export ORACLE_DBA=$ORACLE_SQL/DBA
export ORACLE_MIG=$ORACLE_BASE/MIGRATION
export ORACLE_GEN=$ORACLE_BASE/GENERIC
################################################################
# Main Command Paths for CRON & SCRIPT files                   #
################################################################
export PATH=$PATH:/bin:/usr/sbin
export PATH=$PATH:$ORACLE_BASE:$ORACLE_HOME:$ORACLE_BIN

The next two files called by .profile are not reproduced as they have no relevance for other users. See the section on Functions for a full listing of some very useful code.

Oracle's .profile_READ_ME

Lastly here is the .profile_readme which contains information about all the .profiles for this User ID and how they are used. This file allows all users to be kept up-to-date with new developments as they are added and how best to take advantage of the available facilities.


#!/bin/sh
###################################################################
# .profile_READ_ME (c) R. H. Reepe 29th February 1996 Version 1.0 #
###################################################################
exit
There are a group of files belonging to Oracle, situated in the
oracle_base directory ($HOME for UserID oracle) which start with
the characters ".profile". These files are read into Bourne Shell
scripts with the dot (.) command at the start of each Bourne Shell
script. The files contain information (paths, environment variables,
subroutine definitions, etc.) which the shell scripts can use. The
.profiles are organised as follows:
1	.profile			General Environment Variables
2	.profile_paths			Commonly Used Paths
3	.profile_oracle			Oracle UserID/Password Coded Strings
4	.profile_copyres		Table and Key information for Oracle
5	.profile_references		Database & Server Naming Protocol
6	.profile_function		Bourne Shell Subroutine Suit
7(a-z)	.profile_fun_xxxx		Bourne Shell Subroutine Files
8	.profile_READ_ME		This Document
9	.profile_sql_net_2		Additional DB utilities for SQL-Net 2.0
Currently, all the profiles are read into all scripts at run time.
This may change in the future if the size of the profiles grows too
large and startup time for the scripts starts to slow down. The
special profile for copyres only really needs to be available inside
the copy_resources_db script and so could be moved outside of the
general execution frame for other scripts. However, there is a plan
to create an Oracle Procedure to handle the copy_resources_db
functionality at some future date. There is also the distinct posibility
that the functions for the ftp process may be broken out into a new
profile containing networking funtions only, as they are quite large
and must put additional time into all scripts not using them directly.
There are some simple guidelines to be followed when creating or editing
the profiles:
	1	Only Exported Variables will show up in the Parent Shell
	2	All Exported Variables should be in UPPER_CASE
	3	All External Subroutines should start with s_
	4	Group Like Objects together
	5	Files should be Identical on All Servers
A similar set of guidelines exists for creating and editing Bourne Shell
scripts which is as follows:
	1	All Local Variables should be in lower_case
	2	All Local Subroutines should be declared before calling
	3	All Local Subroutines should NOT start with s_
	4	No ammount of internal documentation is too much
	5	Files should be Identical on All Servers
=====================================================================
INDIVIDUAL PROFILE DETAILS
=====================================================================
.profile
---------
	1	Called by All Bourne Shell Scripts by using [ . $HOME/.profile ]
	2	Contains calls to other General Profiles.
	3	Contains General Setup Variables for APPL Databases.
---------------------------------------------------------------------
.profile_paths
---------------
	1	Used by All Scripts to locate Paths where other Objects live.
	2	Contains a list of Oracle Paths.
---------------------------------------------------------------------
.profile_oracle
----------------
	1	Used by All Scripts to "Aquire" UserID's/Password for Oracle.
	2	Contains Coded Strings of UserID's & Passwords - See Oracle Security.
	3	Strings contain Control Characters - Do NOT Corrupt this file.
---------------------------------------------------------------------
.profile_copyres
-----------------
	1	Used by the copy_resources_db cron script to find the list of Tables to copy.
	2	Contains a list of tables and some primary keys (machines only).
	3	Structure is self evident. Update when new tables are required.
---------------------------------------------------------------------
.profile_references
--------------------
	1	Used by All Scripts that need to know about Servers and Databases.
	2	Contains mapping lists for Databases, Servers, Sites, etc.
	3	See embeded documentation for details.
---------------------------------------------------------------------
.profile_functions
---------------------
	1	Used by All Scripts during execution.
	2	Contains the names of all Function Files loaded during script execution.
	3	Each fun file contains related Functions and Subroutines.
---------------------------------------------------------------------
.profile_fun_xxxx
------------------
	1	Used by All Scripts during execution.
	2	Suit of files containing sets of related Functions and Subroutines.
	3	Be carefull to only call functions after they are defined when nesting.
	4	For a full listing of available funtions type fun at the OS prompt.
	5	Current File List:
		a	.profile_fun_date	  Date and Time Utilities
		b	.profile_fun_file	  File Utilities
		c	.profile_fun_dbas	  Database Utilities
		d	.profile_fun_menu	  Menu Utilities
		e	.profile_fun_strg	  Text String Utilities
		f	.profile_fun_move	  FTP and Mail Utilities
		g	.profile_fun_util   Other Utilities
---------------------------------------------------------------------
.profile_READ_ME
-----------------
	1	This File!
	2	Add to it if required - It's no good if it's out of date!
---------------------------------------------------------------------
.profile_sql_net_2
-------------------
	1	Used by All Scripts during execution.
	2	Dedicated functions for SQL-Net 2.0 support.
	3	Will be integrated into .profile_sub_dbas when complete.
Home Next Preface Introduction Basic Shells Shell Syntax Built-In Commands Command Substitution Startup & Environment Pipes, Lists & Redirection Input & Output Using Files Design Considerations Functions Debugging Putting It All Together Appendix Code Examples Dedication Page 215 This page was brought to you by rhreepe@injunea.demon.co.uk