Questions tagged [environment-variables]

Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.

Environment variables are a set of dynamic-named values that can affect the way running processes will behave on a computer. They can be said in some sense to create the operating environment in which a process runs. For example, an environment variable with a standard name can store the location that a particular computer system uses to store temporary files—this may vary from one computer system to another. A process which invokes the environment variable by (standard) name can be sure that it is storing temporary information in a directory that exists and is expected to have sufficient space.

https://en.wikipedia.org/wiki/Environment_variable

13704 questions
574
votes
7 answers

How to keep environment variables when using sudo

When I use any command with sudo the environment variables are not there. For example after setting HTTP_PROXY the command wget works fine without sudo. However if I type sudo wget it says it can't bypass the proxy setting.
Ahmed Aswani
  • 8,271
  • 7
  • 33
  • 54
546
votes
6 answers

Setting an environment variable before a command in Bash is not working for the second command in a pipe

In a given shell, normally I'd set a variable or variables and then run a command. Recently I learned about the concept of prepending a variable definition to a command: FOO=bar somecommand someargs This works... kind of. It doesn't work when…
MartyMacGyver
  • 9,483
  • 11
  • 47
  • 67
544
votes
16 answers

Set environment variables on Mac OS X Lion

When someone says "edit your .plist file" or "your .profile" or ".bash_profile" etc, this just confuses me. I have no idea where these files are, how to create them if I have to do that, etc, and also why there seem to be so many different ones…
Anders
  • 12,556
  • 24
  • 104
  • 151
539
votes
20 answers

Setting Environment Variables for Node to retrieve

I'm trying to follow a tutorial and it says: There are a few ways to load credentials. Loaded from environment variables, Loaded from a JSON file on disk, The keys need to be as follows: USER_ID, USER_KEY ...This means that if you properly set…
user1107173
  • 10,334
  • 16
  • 72
  • 117
466
votes
23 answers

How to add to the PYTHONPATH in Windows, so it finds my modules/packages?

I have a directory which hosts all of my Django apps (C:\My_Projects). I want to add this directory to my PYTHONPATH so I can call the apps directly. I tried adding C:\My_Projects\; to my Windows Path variable from the Windows GUI (My Computer >…
darren
  • 18,845
  • 17
  • 60
  • 79
452
votes
9 answers

What is the LD_PRELOAD trick?

I came across a reference to it recently on proggit and (as of now) it is not explained. I suspect this might be it, but I don't know for sure.
Hank Gay
  • 70,339
  • 36
  • 160
  • 222
451
votes
13 answers

Can I export a variable to the environment from a Bash script without sourcing it?

Suppose that I have this script: export.bash: #! /usr/bin/env bash export VAR="HELLO, VARIABLE" When I execute the script and try to access to the $VAR, I don't get any value! echo $VAR Is there a way to access the $VAR by just executing…
Salah Eddine Taouririt
  • 24,925
  • 20
  • 60
  • 96
421
votes
17 answers

How to set NODE_ENV to production/development in OS X

For use in express.js environments. Any suggestions?
Mark Nguyen
  • 7,168
  • 9
  • 31
  • 41
398
votes
23 answers

How do I set environment variables from Java?

How do I set environment variables from Java? I see that I can do this for subprocesses using ProcessBuilder. I have several subprocesses to start, though, so I'd rather modify the current process's environment and let the subprocesses inherit…
skiphoppy
  • 97,646
  • 72
  • 174
  • 218
365
votes
20 answers

Where can I set environment variables that crontab will use?

I have a crontab running every hour. The user running it has environment variabless in the .bash_profile that work when the user runs the job from the terminal, however, obviously these don't get picked up by crontab when it runs. I've tried setting…
James
  • 15,085
  • 25
  • 83
  • 120
357
votes
5 answers

Difference between os.getenv and os.environ.get

Is there any difference at all between both approaches? >>> os.getenv('TERM') 'xterm' >>> os.environ.get('TERM') 'xterm' >>> os.getenv('FOOBAR', "not found") == "not found" True >>> os.environ.get('FOOBAR', "not found") == "not found" True They…
André Staltz
  • 13,304
  • 9
  • 48
  • 58
351
votes
12 answers

Recommended way to get hostname in Java

Which of the following is the best and most portable way to get the hostname of the current computer in Java? Runtime.getRuntime().exec("hostname") vs InetAddress.getLocalHost().getHostName()
Mahendra
  • 3,647
  • 2
  • 16
  • 16
349
votes
4 answers

How can I add a default include path for GCC in Linux?

I'd like GCC to include files from $HOME/include in addition to the usual include directories, but there doesn't seem to be an analogue to $LD_LIBRARY_PATH. I know I can just add the include directory at command line when compiling (or in the…
Jesse Beder
  • 33,081
  • 21
  • 109
  • 146
328
votes
12 answers

How to set the environmental variable LD_LIBRARY_PATH in linux

I have first executed the command: export LD_LIBRARY_PATH=/usr/local/lib Then I have opened .bash_profile file: vi ~/.bash_profile. In this file, I put: LD_LIBRARY_PATH=/usr/local/lib export LD_LIBRARY_PATH Then if the terminal is closed and…
singha
  • 3,351
  • 3
  • 13
  • 4
303
votes
7 answers

How do I print a list of "Build Settings" in Xcode project?

Alternate Titles List of Xcode build variables Print a list of Xcode Build Settings Clang Environment Variables Canonical list of Xcode Environment Variables Is there a Canonical list of Xcode Environment Variables that can be used in Build Rules…
Richard Stelling
  • 25,607
  • 27
  • 108
  • 188