Questions tagged [environment-variables]

Environment variables are configuration options that can be set in a shell or other similar environments. All programs started from within the shell can read them and configure themselves.

Environment variables are key-value-pair configuration options like KEY=valueor FOO=bar. Environment variables allow you to configure a program before it gets executed and without the need to store these variables in proprietary configuration files.

They are present on all POSIX systems (Unix, Linux, BSD, Mac OS, DOS, Windows, ...). Environment variables can be set by any shell and read by nearly any programming language.

Some programming languages allow you to set Environment variables, but they only persist within the current process. You can't set them to be visible by the calling shell. So they are not useful for inter-process communication.

410 questions
19
votes
4 answers

Is there a utility to read environment variables from an env file and then run a command (more lightweight than foreman)?

foreman can read .env files and set environment variables from the contents, and then run a program e.g. foreman run -e vars.env myprogram ...but it does a lot of other things (and is primarily concerned with starting things using its Procfile…
wodow
  • 590
  • 1
  • 6
  • 18
19
votes
2 answers

Running shell script with no environmental variables

As I know, newly running shell script inherits it's environment variables. Is there a way to block this? (running shell without variable inheriting)
Eonil
  • 10,459
  • 16
  • 36
  • 54
18
votes
3 answers

How to set $LD_LIBRARY_PATH in Ubuntu?

I need to do this: On linux, we have to find a few dynamic libraries which are not on a standard location. We have to set $LD_LIBRARY_PATH to /path/to/sdk/lib How can I do that in Ubuntu 10.10?
Richard Knop
  • 1,149
  • 2
  • 20
  • 34
17
votes
8 answers

SSH - set env vairables by every connection - godaddy shared host

My problem is, that I have to set env variables (like GIT_EXEC_PATH) on a server. I need that variables by every connection (so by bash and by remote commands either). I managed to set those variables by bash with .bash_profile, but I have problems…
inf3rno
  • 408
  • 2
  • 5
  • 17
17
votes
4 answers

how to export VARs from a subshell to a parent shell?

I have a Korn shell script #!/bin/ksh # set the right ENV case $INPUT in abc) export BIN=${ABC_BIN} ;; def) export BIN=${DEF_BIN} ;; *) export BIN=${BASE_BIN} ;; esac # exit 0 <- bad idea for sourcing the file now these VARs are…
webwesen
  • 945
  • 4
  • 13
  • 21
14
votes
2 answers

Why is "AcceptEnv *" considered insecure?

In /etc/ssh/sshd_config, there is an option called AcceptEnv that allows the ssh client to send environment variables. I need to be able to send a large number of environment variables. These change on every connection from the client, so putting…
TheDauthi
  • 143
  • 1
  • 1
  • 6
13
votes
1 answer

How to use variables in a systemd service file?

I'm creating a service file for a daemon, and I would like to use variables (in init scripts I used environment variables) to define some parameters for the executed scripts. For example, I would like to use 2 parameters $PARAM1…
user886869
  • 245
  • 1
  • 2
  • 10
13
votes
3 answers

Can I use nginx environment variables within static files that nginx serves?

If I use a environment variable in the nginx config, and nginx is configured to serve only static files (html,js,css - e.g. a AngularJs app), is there any way I can use the environment variable within a JS file that nginx serves? Or is the only way…
Tom
  • 4,277
  • 11
  • 42
  • 52
13
votes
1 answer

Security risks of PermitUserEnvironment in ssh

I've read quite a few posts regarding the use of PermitUserEnvironment and the file ~/.ssh/environment in order to pass env variables to an ssh shell. The official sshd docs and a few other resources allude to some security risks of doing this.…
Rob Squires
  • 243
  • 1
  • 2
  • 7
13
votes
4 answers

Environment Variables in PATH Not Expanded for non-Admin Command Prompt?

I have a Windows 7 machine which, when Command Prompt is run by a normal user, fails to expand environment variables in the %PATH%. If command prompt is instead run as administrator (right click, Run as administrator) then %PATH% is appropriately…
12
votes
2 answers

What is the best way to set an environment variable in .bashrc?

When setting up a variable in .bashrc, should I use this? export VAR=value Or would this be enough? VAR=value What is exactly the difference (if there is one)?
Flávio Amieiro
  • 753
  • 2
  • 9
  • 18
12
votes
3 answers

Dynamically Authenticate Apache with LDAP Based on Request String?

It is possible to use a portion of the request URI as an input into mod_authnz_ldap's Require ldap-group directive? I'm trying to dynamically check access to a bunch of different project directories, all under http://testserver.com/projects/, such…
Chris
  • 405
  • 4
  • 8
12
votes
3 answers

Can start-stop-daemon use environmental variables?

I need to daemonize a Windows app running in Wine, and create a pid in /var/run. Since it requires an X11 session to run, I need to make sure the $DISPLAY variable is set in the running user's environment. Assuming I already have a X11 session…
scottburton11
  • 123
  • 1
  • 1
  • 5
11
votes
2 answers

Getting environment variables in PHP-FPM with Nginx

I've defined some environment variables like APP_ENV in my /etc/environment file, on my ArchLinux. If I type printenv, I see them. I've created this simple test file called… test.php
chindit
  • 205
  • 1
  • 2
  • 3
11
votes
3 answers

How do I set the global PATH environment in a batch file?

The group policy in our environment overwrites the PATH variable every time I log on and, as I run a 'non-standard' computer, it gets it completely wrong (C:\Windows vs C:\WINNT, missing directories etc). Currently, I manually change it every time I…
TallGuy
  • 213
  • 1
  • 2
  • 8
1
2
3
27 28