Sponsored Content
Top Forums UNIX for Advanced & Expert Users how to set the environment variable at run time Post 102469 by matrixmadhan on Saturday 18th of March 2006 05:20:33 AM
Old 03-18-2006
to retrieve the old variable from the env
use getenv
and to set new value to env variable as you have said it is
setenv

if you still find some issues, the post the code and how you had tried that?
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How does the PATH and MANPATH environment variable get set?

Hi, How does the PATH and MANPATH environment variable get set? I want to add "/opt/SUNWspro/bin" to the search path for all the users. Where can I access this variable. I know in my home directory, depend on which shell I use, there are files such as .profile and .cshrc which I can edit to... (3 Replies)
Discussion started by: vtran4270
3 Replies

2. UNIX for Advanced & Expert Users

set environment variable?

Installed a program, need to set the system up so that when the executable is entered, it finds the path to the executable. In Windows, set under system properties, advanced, environmental variables. How do I do this with Unix? Specifically using Solaris 9. I have tried: env... (3 Replies)
Discussion started by: kohoutek
3 Replies

3. Shell Programming and Scripting

problem in getting the path of environment variable set in bashrc in my shell script

hi all i have joined new to the group. i have set an variable in my bashrc file. .bashrc PROGHOME=/home/braf/braf/prog export PROGHOME but while using it in my shell script its path is not taken and i had to explicitly give the export command to set the path. in my script... (8 Replies)
Discussion started by: krithika
8 Replies

4. Linux

How do i set environment variable

Hi, I am quite new to Linux. And I have doubt how to set new environment variable with value to a C executable. Let say I have a environment variable $Hack ; I would like to load a value for this variable; so that when the C executable is executed, the $Hack would set the variable value. ... (4 Replies)
Discussion started by: ahjiefreak
4 Replies

5. Solaris

set environment variable?

I am working with solaris 9 sunBlade150 Box. I Installed a program, need to set the environment variable so that when the executable is entered,it finds the path to the executable. The documentation for the software says: Set the appropriate environment variable: Connect to server failed;... (8 Replies)
Discussion started by: smartgupta
8 Replies

6. Shell Programming and Scripting

Set a variable that changes every time?

Do not know how to do this, any help would be appreciated: I have a file that comes in called xxxx.txt. I have a script that does some messing around with the file. The file needs to go out as PAB108XXXX.csv The four x's above will be a number that changes everytime the script is ran e.g.... (1 Reply)
Discussion started by: Pablo_beezo
1 Replies

7. UNIX for Dummies Questions & Answers

ORACLE_HOME environment variable not set!

hi, i am new to perl: os : Linux i wrote simple perl script to select from table i am getting this error and how to set ORACLE_HOME environment variable : script: #!usr/bin/perl use DBI; use Mail::Sendmail; #use Date::Calc; use MIME::QuotedPrint; use HTML::Entities; use POSIX... (2 Replies)
Discussion started by: prakash.gr
2 Replies

8. Shell Programming and Scripting

Set Environment variable from another file

Hi, i have the following env variable. currently i am exporting variable in the same script file. but i need this is in a text file and the scripts need to export this variable from the text file. can you please suggest me. is it possible. export... (6 Replies)
Discussion started by: rsivasan
6 Replies

9. Shell Programming and Scripting

Using same variable in 2 different scripts that run at the same time

Hi, I have two scripts that use the same variable. Say suppose I export that variable in script 1 and try to use it in script 2 where I have declared it locally, what will be the effective value of the variable? Will it take the exported value or the locally declared? example: Script1... (4 Replies)
Discussion started by: PraveenSikamani
4 Replies

10. Solaris

How to search for the sessions that have a certain environment variable set?

Hi all, In Solaris 10, is there a way to search for the sessions that have a certain environment variable set? (8 Replies)
Discussion started by: ejianu
8 Replies
GETENV(9)						   BSD Kernel Developer's Manual						 GETENV(9)

NAME
freeenv, getenv, getenv_int, getenv_long, getenv_string, getenv_quad, getenv_uint, getenv_ulong, setenv, testenv, unsetenv -- kernel environ- ment variable functions SYNOPSIS
#include <sys/param.h> #include <sys/systm.h> void freeenv(char *env); char * getenv(const char *name); int getenv_int(const char *name, int *data); int getenv_long(const char *name, long *data); int getenv_string(const char *name, char *data, int size); int getenv_quad(const char *name, quad_t *data); int getenv_uint(const char *name, unsigned int *data); int getenv_ulong(const char *name, unsigned long *data); int setenv(const char *name, const char *value); int testenv(const char *name); int unsetenv(const char *name); DESCRIPTION
These functions set, unset, fetch, and parse variables from the kernel's environment. The getenv() function obtains the current value of the kernel environment variable name and returns a pointer to the string value. The call- er should not modify the string pointed to by the return value. The getenv() function may allocate temporary storage, so the freeenv() function must be called to release any allocated resources when the value returned by getenv() is no longer needed. The env argument passed to freeenv() is the pointer returned by the earlier call to getenv(). The setenv() function inserts or resets the kernel environment variable name to value. If the variable name already exists, its value is replaced. This function can fail if an internal limit on the number of environment variables is exceeded. The unsetenv() function deletes the kernel environment variable name. The testenv() function is used to determine if a kernel environment variable exists. It returns a non-zero value if the variable name exists and zero if it does not. The getenv_int(), getenv_long(), getenv_quad(), getenv_uint(), and getenv_ulong() functions look for a kernel environment variable name and parse it as a signed integer, long integer, signed 64-bit integer, unsigned integer, or an unsigned long integer, respectively. These func- tions fail and return zero if name does not exist or if any invalid characters are present in its value. On success, these function store the parsed value in the integer variable pointed to by data. If the parsed value overflows the integer type, a truncated value is stored in data and zero is returned. If the value begins with a prefix of ``0x'' it is interpreted as hexadecimal. If it begins with a prefix of ``0'' it is interpreted as octal. Otherwise, the value is interpreted as decimal. The value may contain a single character suffix specify- ing a unit for the value. The interpreted value is multipled by the unit's magnitude before being returned. The following unit suffixes are supported: Unit Magnitude k 2^10 m 2^20 g 2^30 t 2^40 The getenv_string() function stores a copy of the kernel environment variable name in the buffer described by data and size. If the variable does not exist, zero is returned. If the variable exists, up to size - 1 characters of it's value are copied to the buffer pointed to by data followed by a null character and a non-zero value is returned. RETURN VALUES
The getenv() function returns a pointer to an environment variable's value on success or NULL if the variable does not exist. The setenv() and unsetenv() functions return zero on success and -1 on failure. The testenv() function returns zero if the specified environment variable does not exist and a non-zero value if it does exist. The getenv_int(), getenv_long(), getenv_string(), getenv_quad(), getenv_uint(), and getenv_ulong() functions return a non-zero value on success and zero on failure. BSD
October 22, 2013 BSD
All times are GMT -4. The time now is 07:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy