Questions tagged [getenv]

Anything related to C or C++ standard library functions `getenv` (C) or `std::getenv` (C++). These functions are used to get the value of an environment variable.

Anything related to C or C++ standard library functions getenv (defined in <stdlib.h> C standard header) or std::getenv (defined in <cstdlib> C++ standard header). These functions are used to get the value of an environment variable.

See CPPreference.com:

128 questions
2
votes
3 answers

Using getenv function

I have a C program that prints every environmental variable, whose name is given by stdin. It prints variables such as $PATH, $USER but it doesn't see the environmental variables i define myself in the Linux shell... For instance, in bash I define…
shaku
  • 55
  • 3
  • 7
2
votes
3 answers

PHP to Javascript: dirname and document_root

I got a little problem. I am working on a project and I got my root, then I got 2 folders: website1 and website2. website1 is the staff panel, where the upload script is on (where this problem is on). website2 is the website the 'customer' will…
Joshua Bakker
  • 2,288
  • 3
  • 30
  • 63
2
votes
3 answers

Java getenv() returns null

I'm defining an environment variable in a Linux shell with TestEnviron=varproperty. Now, I want to write a small program that reads the environment variable, writes it to the console output, and writes the variable to a properties file. However when…
nick bijmoer
  • 99
  • 1
  • 2
  • 14
2
votes
1 answer

Invalid catalog name: 1046 No database selected

So I'm running this tutorial series that helps you create a light social networking site using Laravel, Gulp and Codeception. I'm at the part where we build the registration form. The layout is done, code is done, user table added. When I goto the…
Halnex
  • 4,242
  • 12
  • 49
  • 102
2
votes
1 answer

PHP getenv() returning only few parameters in Windows

I recently changed the webserver environment on my production system to Apache2.4/mod_fcgid 2.3.9. On restarting Apache, I realized that my scripts depending on the PHP getenv() were broken. Checking further, I could retrieve the Windows PATH with…
Ifedi Okonkwo
  • 3,406
  • 4
  • 33
  • 45
2
votes
1 answer

Android 4.4+ : check if path is on secondary storage

My app has to check if a certain folder is on the secondary storage when the Android version is 4.4+. I am using this: private boolean isPathOnSecondaryStorage(String path) { boolean res=false; String…
P5music
  • 3,197
  • 2
  • 32
  • 81
2
votes
3 answers

When getenv can alter content of previously returned pointer when using glibc?

C standard says that: The getenv function returns a pointer to a string associated with the matched list member. The string pointed to shall not be modified by the program, but may be overwritten by a subsequent call to the getenv…
adashie
  • 616
  • 1
  • 5
  • 15
2
votes
1 answer

retrieve user path environment variable

I try to retrieve the path environment variable on Windows. Therefore, I tried #include #include using namespace std; int main() { char* path = getenv("Path"); cout << "current path is:" << path << endl; cin.get(); //…
Max Beikirch
  • 2,053
  • 5
  • 25
  • 36
2
votes
1 answer

Grails External configuration Config System.getenv

i have code in config.groovy def ENV_NAME = "/home/myFolder" if(System.getenv("ENV_NAME")) { println( "Including configuration file: " + System.getenv("ENV_NAME")); grails.config.locations << "file:" + System.getenv("ENV_NAME") } else { …
rsijaya
  • 159
  • 2
  • 14
2
votes
3 answers

System.getenv("computername") truncating return value

What is the difference between System.getenv("computername") and System.getenv("hostname") in Java? Is there any character limit on the computer name when retrieving it using the getenv() method? I have a lengthy hostname and…
user811433
  • 3,999
  • 13
  • 53
  • 76
2
votes
1 answer

c++ get variable set by call to system()

I am writing a program and i decided for input/output it would be best to allow for custom commands. I have written a config file and defined a series of commands (just echo, etc) and call these within the program using system(). The problem is that…
2
votes
4 answers

Java System.getEnv()

In mac OSX and in Linux CentOS, I insert a new system environment variable (i.e. "MYAPP") using .bashrc & .bash_profile. I even restarted my laptop (mac) and my server (linux). When I use the command line "env", that environment variable showed with…
user1580651
  • 21
  • 1
  • 2
1
vote
1 answer

set System.getenv in Linux

Im building some application, where i would like to get some variable directly from linux. I know, that the command to get the variable is System.getenv(), but i don't exackly know where i should set variable in linux. I'm using Centos, and my…
Ilkar
  • 2,113
  • 9
  • 45
  • 71
1
vote
1 answer

Can I use getenv in daemon process under UNIX environment?

I am writing a daemon process (let's say pA), which is kicked off by a another process(let's say pB), in this daemon pA, I want to use getenv to access a evn variable defined in .cshrc, but to my surprise, getenv returns NULL in pA. I write a…
wangshuaijie
  • 1,821
  • 3
  • 21
  • 37
1
vote
0 answers

About the method and scope of use of setenv()

I want to use setenv() for data transfer as follows: First, I convert an int to string, and then set a variable in a process, for example: setenv(TEST, test, 1) where TEST is the name of the environment variable, test is the converted numeric…
gazile
  • 105
  • 6
1 2
3
8 9