Best way to setup my own environmental variables ?

I am writing a few korn scripts to be used by all our operators on several 4.1/4.2 AIX servers.

I want to create environmental variables that once set, can be read/modified by my scripts (ex: specific folders, file names, conventions, general values, ...). I thought this would be better then simply retyping them in all my scripts and would make maintenance a lot easier.

What would be the best way to do this ?

My scripting level is beginner but mainly because I am very rusty (used to do it a few years back).

One method would be to define common variables in a library file and source it in at the start of the script.

Source them. You write an extra file that contains your standard variables and just source it in all scripts where you need them like:

#/bin/bash

. ./myenv

# here comes the rest of my script
...
...

This way you can also write libraries that contain functions you often use. You can include those external scripts all by using the dot and a blank before the script to be sourced.

---------- Post updated at 04:43 PM ---------- Previous update was at 04:42 PM ----------

As leebix says - sorry I was too slow, got interrupted while writing :smiley:

but what if some of those variables need to have their content changed everyday ?

Most of my intended variables won't change their contant but some will.

ex:
we have a specific file that we use each day in a few tasks. The name is somewhat different everyday. So I want to create an environment variable that will contain that name and be able to change that name everyday so when my script use that variable (by no matter which operator), they will have the right filename in them.

Another option for functions (when using ksh*) is the FPATH variable.

[* Note that in AIX /bin/sh is the same binary as ksh. I know this is true for 5.x and later, verify for yourself on 4.x. Also note that you can use ksh syntax even when called as sh.]

This allows you to maintain a directory of function "files" that will be autosourced when needed.