Operating System - HP-UX
1825904 Members
3662 Online
109689 Solutions
New Discussion

Re: environment variables

 
Kolb
Occasional Contributor

environment variables

hi,
i have simple question: how can i set up environment variables for each user?

Regards
7 REPLIES 7
Pete Randall
Outstanding Contributor

Re: environment variables

This is typically done in a profile: .profile in the user's home directory for an individual or in /etc/profile for variables to be available to all users.

export FOO=bar

for example.


Pete

Pete
Peter Godron
Honored Contributor

Re: environment variables

Hi,
set them up in the users login script, found in the users home directory:
ls -a
for example in .profile
export ORACLE_HOME=/u01/app/oracle/9.2
Peter Godron
Honored Contributor

Re: environment variables

Also,
if you want to set the environment for all users have a look at the scripts in /etc
James R. Ferguson
Acclaimed Contributor

Re: environment variables

Hi Kolb:

You can declare and export environmental variables in a user's profile.

Often, a better approach, however, is to build and export all of the variables in a separate file.

The resulting file can be sourced (read) by the login profile, scripts or applied to a crontab entry.

To source (reaad) one file from another, simply do:

# cat ./sourceme
#!/usr/bin/sh
export WHO=Kolb

# cat ./somescript
#!/usr/bin/sh
. ./sourceme
echo "I am ${WHO}"

Thus sourcing is done by writing a dot (".") followed by a space (" "), followed by the file to source (read).

Regards!

...JRF...
DCE
Honored Contributor

Re: environment variables



You can set them in the users individual .profile located in their home directory.

for example if if you want their prompt to show the the system name and current directory enter the follwing line

export PS1=`uname -n`:'$PWD # '

or to set a command history file:

HISTFILE=$HOME/.sh_history;export HISTFILE

or to set default editor to VI

EDITOR=vi
EXPORT EDITOR


As you can see, there are multiple ways to set the variables.

If the users are using a graphical interface, you will need to either modify their .dtprofile as well, or tell the .dtprofile to read the .profile.


Kolb
Occasional Contributor

Re: environment variables

thanks a lot Good People :)
Oviwan
Honored Contributor

Re: environment variables

Hi

here you have an overview of the login procedure:
http://docs.hp.com/en/A1700-90014/ch03s08.html

Regards