Environment Variables


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Environment Variables

Hi Experts,

Need your help in understanding the commands to setup the environment variables in hp-ux.

Beleive need to use either set,setenv or export.

I am confused between above three options, when to use which option?

On command line, I have tried both set and setenv but couldn't able to set the environment variables. However with export it was working fine.
# 2  
set is used to display the contents of your environment. Issue it and you will get a list of variable=value lines. There are several special variables among these, but it will show you all variables defined in this shell so far.

export is used on variables to have them inherited by processes spawned from this environment.

To explain this in a little more detail: you can start any program from within the shell - even another invokation of this shell. When you declare a variable within a certain shell environment then the program(s) started from this environment does not know about this variable automatically. If the variable is "export"ed it will be known, though.

try the following for yourself:

Code:
# ksh
# x="huhu"
# echo $x
huhu
# ksh               # we start a new environment here
# echo $x           # variable x has no value here, because it was not exported
# exit              # leave the new environment
# echo $x           # we are back in the first one
huhu
# export x
# ksh                # again starting a new environment
# echo $x
huhu
# exit

I hope this helps.

bakunin
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Environment Variables
mahinkhan22
1. The problem statement: What is the mesg value set for your environment? If it is on, how would you turn off your current session? How would you set it permanently? 3. The attempts at a solution : Read Unix The textbook. 3rd chapter has many things like environment variables and...... Homework & Coursework Questions
5
Homework & Coursework Questions
Environment variables
sravani
why are all environment variables represented in a fixed format regardless of the shell you use? like $HOME $PATH etc... UNIX for Dummies Questions & Answers
6
UNIX for Dummies Questions & Answers
environment variables
sumsin
hi, I want to create a new EV(Environment Variable) through a c program and I done this thing through setenv() method. But the newly created EV is not permanent, i.e. when I exit from the program the EV also no longer lives. But I want to make it a permanent EV for the current user. Actually I...... Programming
6
Programming
environment variables
spavlov
Hi Folks, Is it possible somehow to unset all the environment variables which have been defined before in UNIX (Solaris). Thanks, Slava... UNIX for Dummies Questions & Answers
3
UNIX for Dummies Questions & Answers
environment variables
Esaia
Hi! How-to get the environment variables in GNU. getenv() only fetches the ones that you can find under export (not the ones under declare)... best regars .David... Programming
2
Programming