Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [environment-variables]

A set of dynamic variables that can affect the running processes behavior and access to resources.

1
vote
1answer
46 views

Set an environment variable that affects a whole pipeline

How can I set a one-shot variable that affects an entire pipeline? E.g., something like: FOO=1 ./foo.sh && ./foo.sh where foo.sh contains echo "FOO=$FOO" will print: FOO=1 FOO= I would ...
1
vote
2answers
39 views

Why is SHELL pointed to /bin/sh in a Csh script?

Yes, I know C-shell is bad. No, I did not choose C-shell. Yes, I would prefer to use a proper shell. No, I cannot switch to a better shell. I have a very simplistic script: /tmp/env_test.csh #!/...
2
votes
3answers
64 views

How to capture stderr of function that modifies current environment?

The module function of the Environment Modules1 package does its work by modifying various environment variables of the current shell process. Unfortunately, this function returns 0 whether it ...
1
vote
1answer
23 views

How to set environment variables permanently in Amazon Linux 2

I have experimented with many approaches to setting permanent environment variables EC2 instances running Amazon Linux 2, but none of the approaches are persistent across users and across login ...
0
votes
1answer
32 views

How to identify available environmental variables for applications?

On Linux, the crontab editor can be configured to open with nano using the following command: $ EDITOR=nano crontab -e This "EDITOR" env is mentioned in the crontab manual, but is there a way to ...
1
vote
1answer
28 views

Populate environment in non-interactive session

I'm working on an embedded device that runs Yocto Poky as distro. The final product will have several applications that are started by SysVinit. There is only one root user. I have some scripts, ...
-1
votes
1answer
14 views

multi-line export without a newline

How can I export something that's multiline? export foo='bar a ab ai ii bar' and put that on two different lines without a newline literal? export foo='bar a ab ...
1
vote
2answers
69 views

Save variable from initramfs (at boot time)

How can I save environment variables at boot time before the real filesystem has been mounted ? I know there is /etc/environment but whithin initramfs that file is not accessible yet. I also thought ...
0
votes
0answers
48 views

Is to possible to know the source of environment variables? [duplicate]

I have an environment variable lingering around my terminal that I have not set anywhere. Let us assume that environment variable to be "alpha". I know that the sources from which environment ...
0
votes
1answer
25 views

Difference between `MYVAR=1 /bin/whatever` and `env MYVAR=1 /bin/whatever`? [duplicate]

They both seem to do pretty much the same thing, but what are the advantages of using one over the other?
-1
votes
3answers
105 views

Is this allowed in an `if statement`?

# optional cropping if [ "$1" == "cropit" ]; then ITS_CROP_TIME= mkdir cropped; for i in *.mp4; do ffmpeg -i "$i" -filter:v "crop=1920:980:0:-100" cropped/"${i%.*}.mp4" rm -r *.mp4 cd ...
1
vote
1answer
19 views

Writing logs for openvpn in Ubuntu18

I've installed openvpn on Ubuntu18, and it works. I'd like to have a log containing only the times when users connect and disconnect. Found a hint how to do it at [https://github.com/furlongm/openvpn-...
0
votes
2answers
10 views

Build path name with variable as input to touch [duplicate]

I want to store a path I often use as an environment variable, then call this variable to construct a path name. $ mypath="~/local/bin/" $ newFile="${mypath}newFile.sh" $ echo $newFile ~/local/bin/...
0
votes
0answers
45 views

Write stdout to a temp file using command line

Say for example we wanted to write the env from the host to Docker container, one way would be to use a temp file: env > env_file && docker run --env-file env_file image_name to avoid a ...
5
votes
3answers
2k views

Does FOO=bar; export the variable into my environment?

If I run FOO=bar docker run -it -e FOO=$FOO debian env That environment variable is not set in the command output for the env command. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/...
0
votes
2answers
49 views

Confused about Configuring Linux Path Environment /etc/profile.d/*.sh being Executed Twice?

I am trying to set PKG_CONFIG_PATH to CentOS here are the code I tried export |grep PKG_CONFIG_PATH no output, normal... echo "$PKG_CONFIG_PATH" :/usr/local/lib/pkgconfig why there is output here??...
4
votes
6answers
3k views

shebang or not shebang

I want to use a program in the shebang, so I create a script named <myscript> with: #!<mypgm> I also want to be able to run <mypgm> directly from the command prompt. <mypgm> ...
2
votes
0answers
32 views

Add file to PATH only when in specific directory [duplicate]

Is it possible to make executable appear in the global search path when I am entering to the some specific directory and get it removed once directory changed again?
1
vote
0answers
17 views

Tracing environment variable modification

Pesky $PATH, there's one item I used to use ~/.workspace/bin. I just can't figure where its coming from. I changed the user shell to /bin/sh, and logged in from tty, checked PATH, and it was clear of ...
0
votes
1answer
30 views

How to check “eval” command?

My code docker-machine create --driver virtualbox dev VBoxManage list vms "minikube" {9c326ed5-faf4-42fe-acda-bf3a283f1a74} "kalinew" {de6de631-0d51-4638-b967-66db463cbf05} "dev" {84a116bf-02b9-...
0
votes
0answers
22 views

Emacs launched from command line and standalone Emacs have different syntax highlighting when using the same theme (solarized)

I have set export TERM=xterm-256color, however when I launch Emacs in terminal vs. the standalone app the syntax highlighting has different colors. What do I need to do to make them the same?
5
votes
1answer
435 views

How important is it that $TERM is correct?

I recently switched from rxvt-unicode to st. This means I went from $TERM=rxvt-unicode-256color to $TERM=st-256color. I'm happy with the switch and want to continue to use st. However, I've noticed ...
0
votes
1answer
33 views

Exported Date Variable not appearing in subshell

I'm currently working on creating 2 bashes with two different scripts which result in two files named with the same timestamp for easy comparison/processing later. The date variable gets created in ...
0
votes
0answers
33 views

Knowing what directory a process started in

I'd like to be able to know mid-working what directory a child process started in. Here I'm in a Bash session, I start a dash session and I'd like to know where did dash start (in the example it ...
1
vote
0answers
33 views

Ruby script is not picking up sourced env vars

I am using environment variables in a Ruby script. When I export the variables and run the script as follows, it works fine. export ELK_URL="https://localhost:3241" ruby ./my_script.rb The contents ...
0
votes
0answers
14 views

Gnome3 Session Startup File

What is the location of the "Gnome3 Session Startup File". I use Ubuntu 18.04 with gdm3 as display manager. I want to export an environment variable (persistent) for GUI (desktop) application. Also,...
0
votes
1answer
130 views

$EDITOR environment variable won't set

Whenever I attempt to set the EDITOR environment variable, a subsequent check reveals no value has been set. I was attempting to edit the crontab: sudo crontab -e -u mycooluser which returns: no ...
0
votes
2answers
127 views

creating OS environment variables using ExecStartPre on Systemd

I have the following unit file: [Unit] Description=Panel for Systemd Services After=network.target [Service] User=pysd Group=pysd PermissionsStartOnly=true WorkingDirectory=/opt/pysd ExecStartPre=/...
0
votes
1answer
53 views

How to view the binary contents of environment variables?

I'm practicing CTFs (capture-the-flag) and want to view the contents of an environment variable: MyEnv=`python3 -c 'print(64*"A"+"\x0a\x09\x0a\x0d",end="")'` Now, hexdump displays the following, ...
0
votes
1answer
13 views

how does the expression b=${b:-“/data”} work [duplicate]

I've run a cross a shell script with BUILDDIR=${BUILDDIR:-"/data"} which , upon experimentation, takes the original BUILDDIR if it exists and isnt an empty string, and otherwise sets it to /data. What ...
0
votes
1answer
162 views

Debian Linux - Setting an environment variable for all users

I added the following in /etc/profile so that all my users can see the path export JAVA_HOME=/opt/jdk11 export PATH=$PATH:$JAVA_HOME/bin But after restarting my laptop, I cannot see the changes ...
1
vote
2answers
304 views

Bash environment variables in non interactive mode

I'm trying to define environment variable for non-interactive console in Raspbian. In theory I need to add the varaibles to ~/.bashrc or ~/.profile or /etc/bash.bashrc or /etc/profile. For example I ...
5
votes
3answers
1k views

Equivalent to “source” in OpenBSD?

Trying to open a python3 virtual environment I have created with python3 -m venv myVenv by doing source myVenv/bin/activate as I do in Linux, but I get ksh: source: not found which mean it is ...
0
votes
0answers
34 views

How do I get CRON to run a script that works in my regular shell, but not in CRON? [duplicate]

I am running Ubuntu 18.04 LTS on an Amazon LightSail instance. When I try to run a Python script as soon as I log, it runs perfectly. I run my script with the full path in with the command: /usr/bin/...
1
vote
1answer
259 views

How to persist environment variables in ash, the Almquist shell?

How can I get ash to load some environment variables on startup? Just put them in /etc/profile /etc/profile is only read for login shells; what about non-login shells, as frequently pop up when ...
0
votes
1answer
588 views

How to change default text edior for virsh edit? (setting EDITOR env variable didn't work)

I recently installed virt-manager on an Arch Linux install, and unlike under Ubuntu, I was not prompted to choose a text editor on the first launch of virsh-edit. Instead, the XML file was opened in ...
0
votes
0answers
40 views

HTTPS=true is not working [duplicate]

I'm trying to set the environment variable HTTPS=true in macOS bash shell but it doesn't work when I printenv the variable HTTPS=true doesn't appear: TERM_PROGRAM=Apple_Terminal SHELL=/bin/bash TERM=...
0
votes
1answer
32 views

Comparing working directory with “string” [duplicate]

I'm trying to compare the current working directory's path with my home directory's path. user@machine:~$ echo $PWD /home/user user@machine:~$ if ["$PWD" = "/home/user"]; then echo True; else echo ...
0
votes
0answers
58 views

Init script not picking up environment variable set in /etc/environment?

What is the right way to set a global environment variable, such that it is picked up all processes, including those started via init.d (service <service> start), on Ubuntu? Details: I first ...
0
votes
3answers
62 views

Which quoting style GNU Bash variable definitions (mostly for paths)? [closed]

Which of the following quoting styles, for GNU Bash variables, is preferred and why? Two double quotes: VAR="/path/$V1/path with space/$V2". Multiple double quotes: VAR=/path/"$V1"/"path with space"/"...
0
votes
0answers
53 views

How do I prevent module load conflicts (environment modules)?

I am setting up Environment Modules for a server and have two modules: test1 and test2. Test1 needs java 1.7.0 and test2 needs java 1.8.0. If I use prereqs/conflicts, as seems to be standard ...
1
vote
1answer
235 views

How do I properly change the debian default python 2.7.9 to python3 or another version? [duplicate]

what is best-practice for changing the default global python interpreter on my fresh debian-based linux node to python3.x? When I create a fresh Debian or Ubuntu VM, one of the first things I do is ...
1
vote
1answer
50 views

My Java environment variables seem to be a complete mess how do I make a clean start without reinstalling?

I am trying to get Janusgraph working on OpenSuse Leap 42.3 but I'm running into a multitude of problems. My understanding is that JanusGraph invokes other Java dependencies, including gremlin & ...
1
vote
0answers
185 views

How can I set and export an environment variable in a systemd service?

after starting agetty on my Raspberry Pi in order to attach a VT420 terminal to it, I still have an issue: The shell language must be set to en_US and exported by hand right after logging in on the ...
4
votes
1answer
177 views

Bash can't find scripts in $PATH [closed]

I'm setting up a completely new, fresh Ubuntu 16.04 Minimal system, and have run into a weird problem. Even after adding $HOME/bin to the $PATH, bash can't seem to find any of the scripts in it, at ...
2
votes
1answer
104 views

Why is my BASH_FUNC_foobar%% environment variable unset in shell subprocesses?

I'm messing around with the security of a setuid binary (with the intention of disclosing anything I find to the author, obviously). I'm pretty sure it has an arbitrary code execution vulnerability ...
0
votes
2answers
366 views

Eval and exec with variable substitution

I'd like to execute a statement to start a server. For that I have an environment variable to determine which server is to be started. I was given this command as a starting point: eval "exec ...
0
votes
0answers
21 views

set env variable apache when accessing a specific url

is there a way to take a user id sent in the http header and to rewrite it to a variable "remote_user" but only when accessing a particular URL? I'm aware of SetEnv but that doesn't do the trick I ...
0
votes
1answer
88 views

How do I use ssh-agent as a wrapper program?

I'm trying to start awesome windows manager as a subprocess of ssh-agent. It worked when I used startx (ssh-agent startx). But now I'm trying to make it work under lightdm. lightdm starts /usr/bin/...
0
votes
1answer
268 views

Java-like properties file to environment variables

I need to convert each property of a properties file to a environment variable: I mean, guess this property file: mongo.port=27017 mongo.host=127.0.0.1 mongo.databaseName = test bo.url-jwt=https://...