Operating System - HP-UX
1826325 Members
3500 Online
109692 Solutions
New Discussion

Setting Environment Variables

 
SOLVED
Go to solution
John Smoltz
Occasional Contributor

Setting Environment Variables

I am new to HP-UX and am having difficulties finding out where to setup environment variables. I am using the Bourne shell and am trying to setup the variable below:

AGENT_DIR=/opt/agent/service

Where would I set this to make it permenent and what is the syntax.

Thanks
9 REPLIES 9
Victor BERRIDGE
Honored Contributor

Re: Setting Environment Variables

I forgot the syntax:
export
Thats all...
Victor BERRIDGE
Honored Contributor

Re: Setting Environment Variables

in your .profile, or /etc/profile for all

Regards
Victor
John Smoltz
Occasional Contributor

Re: Setting Environment Variables

I set the variable in the .profile file and logged out. When I run echo $AGENT_DIR it comes up blank.
Rick Garland
Honored Contributor

Re: Setting Environment Variables

Can set in the /etc/profile using the syntax of
AGENT....=...
export AGENT...

This would be global for all users. If you are looking for a particular to have this variable, use the $HOME/.profile.
Antoanetta Naghiu
Esteemed Contributor

Re: Setting Environment Variables

Generally for all users in the machine, go and edit /etc/profile

If you were new, do:
cp /etc/profile /etc/profile.16.08.00 (make a copy of the current)
vi profile
VAR=whatever
export VAR

If you want it for a particular user, in $HOME/.profile ( in .profile of that specific user's home directory). For root is the same available. If root's home dir is / modify /.profile with the same entry.

For cshell, the file to be modified is .login and the command is the same with set in front of.
Victor BERRIDGE
Honored Contributor

Re: Setting Environment Variables

Are you using an X emulation? or are you in Xwindows? in that case you would be using a .dtprofile and not reading your .profile...
Vikas Khator
Honored Contributor
Solution

Re: Setting Environment Variables

Hi,

Also remember to export the variable after setting it.

In case you are using the CDE environment ensure that your .dtprofile has DTSOURCEPROFILE set to true otherwise it won't source your .profile.

Also ensure that you set your *loginShell to TRUE in your /etc/dt/config/C/sys.resources file. If the file doesn't exist it should be under /usr/dt/config/ .

Hope this helps.
Keep it simple
John Smoltz
Occasional Contributor

Re: Setting Environment Variables

Thanks all...It was referencing the .dtprofile and when I uncommented it, it worked....Thanks for your help!
Alex Glennie
Honored Contributor

Re: Setting Environment Variables

One last point wrt X / CDE or VUE, if you find at somepoint the variable isn't picked up in say hp,dt or an xterm window run the dt,x or hpterm window with the command line option -ls, it'll force the terminal client to read yor .profile without the need to set the variable in your .dtprofile see man hpterm etc for details : also can be set in a file $home .Xresources : man pages have the syntax but off the top of my head :

hpterm*loginShell :True should do the trick