Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

setenv(3) [ultrix man page]

getenv(3)						     Library Functions Manual							 getenv(3)

Name
       getenv, setenv, unsetenv  - manipulate environment variables

Syntax
       char *getenv(name)
       char *name;

       setenv(name, value, overwrite)
       char *name, value;
       int overwrite;

       void unsetenv(name)
       char *name;

Description
       The  subroutine	searches  the  environment  list for a string of the form name = value and returns a pointer to the string value if such a
       string is present, otherwise returns the value 0 (NULL).  For further information, see

       The subroutine searches the environment list in the same manner as If the string name is not found, a string  of  the  form  name=value	is
       added  to  the environment.  If it is found, and overwrite is non-zero, its value is changed to value.  The subroutine returns 0 on success
       and -1 on failure, where failure is caused by an inability to allocate space for the environment.

       The subroutine removes all occurrences of the string name from the environment.	There is no library provision for completely removing  the
       current environment.  It is suggested that the following code be used to do so.
       static char     *envinit[1];
       extern char     **environ;
       environ = envinit;
       All of these routines permit, but do not require, a trailing equals sign (=) on name or a leading equals sign on value.

See Also
	csh(1), sh(1), execve(2), putenv(3), environ(7)

																	 getenv(3)

Check Out this Related Man Page

getenv(3C)						   Standard C Library Functions 						getenv(3C)

NAME
getenv - return value for environment name SYNOPSIS
#include <stdlib.h> char *getenv(const char *name); DESCRIPTION
The getenv() function searches the environment list (see environ(5)) for a string of the form name=value and, if the string is present, returns a pointer to the value in the current environment. RETURN VALUES
If successful, getenv() returns a pointer to the value in the current environment; otherwise, it returns a null pointer. USAGE
The getenv() function can be safely called from a multithreaded application. Care must be exercised when using both getenv() and putenv(3C) in a multithreaded application. These functions examine and modify the environment list, which is shared by all threads in an application. The system prevents the list from being accessed simultaneously by two different threads. It does not, however, prevent two threads from successively accessing the environment list using getenv() or putenv(3C). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
exec(2), putenv(3C), attributes(5), environ(5), standards(5) SunOS 5.11 24 Jul 2002 getenv(3C)
Man Page

7 More Discussions You Might Find Interesting

1. Programming

environment variables

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 (2 Replies)
Discussion started by: Esaia
2 Replies

2. UNIX for Advanced & Expert Users

Reset environment - ".. /etc/.environment dev_env"

I have been resently working on some ksh script. One of the line in the file writes: .. /etc/.environment dev_env I can not understand what this mean, all I know is .environment is unix system environment file. Is ".." a command? If some one can give me some clue where can I find information... (7 Replies)
Discussion started by: zzwu3591
7 Replies

3. UNIX for Dummies Questions & Answers

removing leading zero

Hi, I do have a code as follows: function deHex { if ]; then deHexDate=${1:1:$2} fi } The description given for the above code is as follows: # description: removes leading zero so value will not be recognized as hex # usage: deHex <value_parameter> <value_input_length> ... (0 Replies)
Discussion started by: risshanth
0 Replies

4. Shell Programming and Scripting

Perl Scripting

There is a function in Perl named PerlEnv_getenv() which is equivalent to getenv() in C. It invokes the environment variable. It uses the library the library perlclib.How to define this library and use the Perl function? (3 Replies)
Discussion started by: agarwal
3 Replies

5. Programming

Memory fault(coredump) while using Environment variables

Hi, Actually I am facing one issue while using the getenv() in the C/C++ program. I want to take the file path from environment variables and if am not defining the environment path, its showing the message like this…! Memory fault(coredump) Actually I want to handle the error ,... (6 Replies)
Discussion started by: Kattoor
6 Replies

6. Programming

Cast from String to char

Hello, This is my code: i'd like to like to add getenv("MYLIB") in the first case of my buffer inside of '1' , should i do the cast ? and how please ? Thank you. (1 Reply)
Discussion started by: chercheur857
1 Replies

7. Shell Programming and Scripting

Remove leading and trailing spaces from a file

Hi, I am trying to remove leading and trailing spaces from a file using awk but somehow I have not been able to do it. Here is the data that I want to trim. 07/12/2017 15:55:00 |entinfdev |AD ping Time ms | .474| 1.41| .581|green |flat... (9 Replies)
Discussion started by: svajhala
9 Replies