Operating System - HP-UX
1833059 Members
2353 Online
110049 Solutions
New Discussion

Re: Change environment variable for process?

 
SOLVED
Go to solution
Coolmar
Esteemed Contributor

Change environment variable for process?

Is it possible to set environment variables for UNIX processes? This question arises from the fact that Esri's ARCSDE 9.1 has a “bug” with it that doesn’t allow you to enter different languages into the Oracle database. There’s an environment variable you can set called NLS_LANG which can override the default values in the database, but of course you have to set it for that particular UNIX process/connection. Is there a way once someone has started a UNIX process that you can change environment variables for that particular process?
7 REPLIES 7
Steven E. Protter
Exalted Contributor
Solution

Re: Change environment variable for process?

Shalom Sally,

You can set an environmental variable when launching a process. Once its running, its kind of hard to change its environment, unless its an interactive process and programmed for it.

If you have an interactive script, written to accept input and change environment variables, that process could be affected the way you wish.

if you knew a process(script whatever) was going to read a file for environment information and its already written to do this, you can have an impact on it while its running.

But usually when a process is running it has its environment and can't accept input from sources its not designed to accept input from.

Summary: Probably not.

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
Victor Fridyev
Honored Contributor

Re: Change environment variable for process?

Hi,

If the user, which you work with, run sh or ksh, put into ~user/.profile the following string:
export NLS_LANG=What.Ever.YouWant
If you work with csh, add to .cshrc
setenv NLS_LANG What.Ever.YouWant

HTH
Entities are not to be multiplied beyond necessity - RTFM
A. Clay Stephenson
Acclaimed Contributor

Re: Change environment variable for process?

A process is allowed to change its own environment via the putenv() function but the application has to make provisions to call this function. You least evil option would be to create a wrapper script which prompts for the enviroment and then sets and exports the variable and then invokes your application as a child process.
If it ain't broke, I can fix that.
Coolmar
Esteemed Contributor

Re: Change environment variable for process?

Thanks Steven, that is what I figured but thought I would pose the question just in case. Thanks for the input.

Thanks Victor, but I need the env. changed for the *process* itself not at the user level.
Bill Hassell
Honored Contributor

Re: Change environment variable for process?

Changing an environment value on the fly doesn't make much sense. Once the process starts, the language is set and any access or change made prior to a possible change in the environment variable would be in the wrong language. So as mentioned, each process that needs to use a non-default NLS_LANG value must have the value set before starting the process.


Bill Hassell, sysadmin
Coolmar
Esteemed Contributor

Re: Change environment variable for process?

Yeah, it is a "bug" in the application and the vendor doesn't have a fix other than upgrading to the next version which isn't even out yet. So I guess we will just have to wait for the next version.

Thanks everyone,
sd
Coolmar
Esteemed Contributor

Re: Change environment variable for process?

n/t