Operating System - HP-UX
1834449 Members
2104 Online
110067 Solutions
New Discussion

Setting Unix User Envirment Variables

 
SOLVED
Go to solution
Rizwan Choudhry
Advisor

Setting Unix User Envirment Variables

Hi,
I need to setup following user enviroemnt variable.

SHLIB_PATH=/usr/sap/D06/SYS/exe/run:/oracle/D06/920_64/lib

Do i use set command
or Export command
Whats is the difference between SET and Export?

Also what would be correct command syntax

set SHLIB_PATH=/usr/sap/D06/SYS/exe/run:/oracle/D06/920_64/lib

export SHLIB_PATH /usr/sap/D06/SYS/exe/run:/oracle/D06/920_64/lib

Thanks in Advance



rizzir
8 REPLIES 8
Yogeeraj_1
Honored Contributor

Re: Setting Unix User Envirment Variables

hi Rizwan,

SET is used in the Windows environment to set Environment variables whereas EXPORT is used in the Unix Environment.

For more information, please see "man set" and "man export"



hope this helps!
kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Steven E. Protter
Exalted Contributor

Re: Setting Unix User Envirment Variables

Shalom,

set makes the variable available for this command session.

export makes it available for child processes as well.

I generally set and export the variable to make sure its available, though there are exceptions, depending on the application to be run.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
VK2COT
Honored Contributor

Re: Setting Unix User Envirment Variables

Hello,

Both your answers are correct!

Here is the difference and why you need
to use one or the other:

It all depends on the Shell you use.
For Shells like Ksh, Bash, Posix Shells,
and classical Sh, you would use:

export SHLIB_PATH /usr/sap/D06/SYS/exe/run:/oracle/D06/920_64/lib

For Cshell, you would use:

setenv SHLIB_PATH=/usr/sap/D06/SYS/exe/run:/oracle/D06/920_64/lib

Cheers,

VK2COT
VK2COT - Dusan Baljevic
Yogeeraj_1
Honored Contributor

Re: Setting Unix User Envirment Variables

>Also what would be correct command syntax

$ set SHLIB_PATH=/usr/sap/D06/SYS/exe/run:/oracle/D06/920_64/lib
$ echo $SHLIB_PATH
sh: SHLIB_PATH: Parameter not set.
$ export SHLIB_PATH /usr/sap/D06/SYS/exe/run:/oracle/D06/920_64/lib
sh: /usr/sap/D06/SYS/exe/run:/oracle/D06/920_64/lib: This is not an identifier.
$ export SHLIB_PATH=/usr/sap/D06/SYS/exe/run:/oracle/D06/920_64/lib
$ echo $SHLIB_PATH
/usr/sap/D06/SYS/exe/run:/oracle/D06/920_64/lib
$


kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Jeeshan
Honored Contributor

Re: Setting Unix User Envirment Variables

if you need to setup environment variable permanently set it to the .profile

SHLIB_PATH=/usr/sap/D06/SYS/exe/run:/oracle/D06/920_64/lib

export SHLIB_PATH
a warrior never quits
Dennis Handly
Acclaimed Contributor
Solution

Re: Setting Unix User Envirment Variables

>Do i use set command or export command? What's is the difference between set and export?

As mentioned by Dusan, it depends on which shell you use. If you use a real shell you use export. If you use the scummy csh, you use setenv.

The set command in a real shell only works on arrays. For the scummy csh, it doesn't export the variable.

>yogeeraj: For more information, please see "man set" and "man export"

You'll need to look at ksh(1), posix-sh(1) or csh(1) for the individual commands.

>Dusan: For shells like ksh, bash, Posix Shells
>export SHLIB_PATH path1:path2
>For cshell, you would use:
>setenv SHLIB_PATH=path1:path2

The syntax is backwards, export needs the "=".

>ahsan: if you need to setup environment variable permanently set it to the .profile

Unless you use this user to only run a particular set of apps that only need this SHLIB_PATH, I would only export SHLIB_PATH/LD_LIBRARY_PATH in the script that invokes each application.
Rizwan Choudhry
Advisor

Re: Setting Unix User Envirment Variables

Thanks All for your help,
Information provided has been very usefull.
rizzir
VK2COT
Honored Contributor

Re: Setting Unix User Envirment Variables

Hello,

Thanks to Dennis for the correction.
My fast typing again.

I am actually the fastest two-finger
typing person on the east coast of
Australia :) Not always the most
precise one though :)

The correct syntax (as we all know):

For BASH, Ksh, Posix Shells:
export SHLIB_PATH=/usr/sap/D06/SYS/exe/run:/oracle/D06/920_64/lib

For Cshell:

setenv SHLIB_PATH /usr/sap/D06/SYS/exe/run:/oracle/D06/920_64/lib

Sadly, even after 23 years in Unix,
I cannot use all fingers when typing...

VK2COT
VK2COT - Dusan Baljevic