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
1
vote
2 answers

How can I access environmental variables with WAMP server?

I'm trying to adapt my code to use different database password etc depending on the environment it runs in. For example, I have my dev server, the other developer has his and production env has yet another set of settings. Since I have some Kohana…
Henno
  • 1,448
  • 4
  • 18
  • 30
1
vote
0 answers

Why get env vars in php 7 is not working?

Well, I'm trying to use a env var value in PHP 7.2 something like this $var1 = getenv('AWS_REGION'); [some code bla bla bla] echo $var1; but returns this Expected string, but got bool(false) Even I do echo the var and nothing happens echo…
Gamaor
  • 85
  • 3
1
vote
0 answers

System.getenv with special characters like '%' in Java

My JAR runs in a DOS shell like this set MY_VAR=MY_VALUE my_jar.jar MyClass and in MyClass I code String myValue = System.getenv("MY_VAR"); System.out.println("myValue = " + myValue); This works fine. But now I must change in my DOS shell the…
1
vote
2 answers

store or check value of getenv() only once in a shared library/DLL

I have a function to print debug logs which has to be toggled depending on the environment variable. Instead of checking the env var each time the print_trace() is called, what should be the best method to store it and reuse that value? void…
a11apurva
  • 138
  • 10
1
vote
0 answers

how to allow Java System library to access a variable defined in .zprofile?

So I am trying to use spring tools along with maven to develop java applications on a mac system using zsh. Invoking System.getenv(var_name) returns null, it is clear to me that System library can't access variable defined in .zprofile on my mac, is…
mansanto
  • 360
  • 4
  • 16
1
vote
0 answers

IDL syntax error caused by getenv(), a path error

I am using exofast code in IDL, I set environment exactly as the developer describe it but when I ru the code for fitting I get this errors: path = filepath('',root_dir=getenv('EXOFAST_PATH'),subdir=['examples','hat3']) …
1
vote
3 answers

Does getenv return heap memory that I can reallocate to?

Ok, so I need to concatenate results to getenv. I am not allowed to define any other variables. If getenv returns heap pointers, then can I realloc it, to concatenate? Yes, or not?
user12216514
1
vote
1 answer

C program getenv() returns null despite terminal echo working

I have read all the other posts with the same title, but I'm not on an embedded system, and I have my includes and environment variable set correctly. Running on RHEL 7.5, my program with getenv wasn't working so I created a C application with the…
Kyle
  • 97
  • 5
1
vote
1 answer

How to fix system.getenv error while running through maven command?

I am running a project on eclipse through maven and I have set an environment variable on my system for my project to work. Here is a sample code: public class StepDefFile { WebDriver driver = CaptureScreenshot.driver; public static String…
sshinde
  • 13
  • 3
1
vote
2 answers

Cloudflare is giving me the wrong IP when I use getenv(REMOTE_ADDR)

I have a test php code. Which essentially grabs the IP of someone and emails it to an address. I plan later on storing it in a database, but just for testing purposes I have put it as emailing me. My issue is, I have cloudflare enabled so when I use…
Mikie
  • 125
  • 1
  • 7
1
vote
2 answers

how to override an environment variable for different test cases in nodeJS?

I am using dotenv to load the .env file, but I need to run the test cases for different values of a particular environment variable. But unfortunately, once loaded dotenv does not let me change the value of the env variable, I can not reset the…
Prerna Rana
  • 95
  • 1
  • 9
1
vote
2 answers

Supervisor not using /etc/environment

I have an script in PHP that prints an environment variable set in /etc/environment with getenv. It works fine when I execute it manually, but when is executed by supervisor, it doesn't work. I don't want to put manually this environment variable on…
1
vote
1 answer

using C to generate simple html page with cgi

C program: #include #include int main() { char *data = getenv("QUERY_STRING"); char userName[30]; sscanf(data,"uname=%s", userName); printf ("Content-Type: text/html\n\n"); printf (""); printf…
mcgillian
  • 97
  • 7
1
vote
0 answers

In php, environment arrays are not passed in

If I declare an array in the shell environment, it does not appear in PHP. A scalar works fine. E.g.: Shell script: declare -a TARGETS TARGETS[0]="/etc" TARGETS[1]="/boot" export TARGETS export HOST="localhost" PHP: $TARGETS = array…
IT Fixt
  • 11
  • 3
1
vote
2 answers

C++ getenv() wrapper function not setting the value

The cplusplus.com documentation on getenv() states... The pointer returned points to an internal memory block, whose content or validity may be altered by further calls to getenv ...which I take to mean, "If you want to keep the content, copy it."…
alanlittle
  • 460
  • 2
  • 12
1 2 3
8 9