Tagged Questions

A set of dynamic variables that can affect the running processes.

learn more… | top users | synonyms

1
vote
1answer
84 views

Multiple MODULEPATH entries in .modulesbeginenv

I'm switching between paths/code projects. At each place I have different modules. To handle this there is a setup script that modifies what to use. This is handled with the tool 'module'. NOTE: ...
0
votes
0answers
33 views

Parameters files, pfiles director: how to overwrite default settings

This is a quite general question that I am not sure to be able to address correctly. I must manage some bash or tcsh scripts that invoke other software's tools. These tools are invoked by name and ...
7
votes
1answer
2k views

how to set environment variables from a shell script? [duplicate]

I'm trying to set environment variable through a shell script. Here is the script with various techniques: #!/bin/sh echo "export SOMEPATH=/root/some" >> /root/.bash_profile echo "export ...
6
votes
2answers
281 views

if statement in .bashrc not working correctly

I set up .bashrc to show a long prompt if the terminal is at least 80 characters wide. Otherwise it shows a degraded, smaller prompt. I use an if statement to achieve this: dp_smaller_than=80 if [ ...
2
votes
1answer
51 views

What does the period indicate when an environmental variable is set like “VARIABLE_NAME=.”

What does the period indicate when an environmental variable is set like VARIABLE_NAME=.
5
votes
3answers
335 views

Is there any harm in using variables that aren't set?

Say I have the following code: # Check if the color prompt is enabled and supported on this system if [ -n "$force_color_prompt" ] && [ -x /usr/bin/tput ] && tput setaf 1 ...
2
votes
2answers
169 views

How to guarantee availability of $BASH_ENV

A non-interactive, non-login shell will try to source any script specified in $BASH_ENV. But how do I guarantee $BASH_ENV is set before a cron job or script has a chance to set $BASH_ENV for any ...
1
vote
2answers
805 views

Setting PATH vs. exporting PATH in ~/.bash_profile [duplicate]

What's the difference and which is better to use when customizing my bash profile? Documentation on the export command is scarce, as it's a builtin cmd. Excerpt from version 1 of my ~/.bash_profile: ...
2
votes
0answers
23 views

Why does xdg-open text_file differ from sudo -u me xdg-open text_file?

If I run the following command, the text file opens in my preferred editor (kate). $ xdg-open text_file However, if I try the following, where sparhawk is my username, I get several warnings, and ...
5
votes
1answer
79 views

What else can break if I remove export from a variable?

My problem is that when I started coding my script I encountered several variable scope issues which resulted in the bad habit of exporting almost all my variables. Now that my code has got quite ...
3
votes
4answers
119 views

Protected environment variables?

Are there names of environment variables that cannot be overwritten by the user/a call to setenv? As I understand from POSIX1.2008, any process may edit the environment block, but must avoid ...
1
vote
2answers
813 views

How do I get a variable's value from one script and import it in another script?

How do I get a variable's value from one script and import it in another script? But the catch is that the script where I am going to get the variable's value has also some commands that I don't want ...
4
votes
3answers
261 views

Environment variables are not set when my function is called in a pipeline

I have the following recursive function to set environment variables: function par_set { PAR=$1 VAL=$2 if [ "" != "$1" ] then export ${PAR}=${VAL} echo ${PAR}=${VAL} shift ...
2
votes
4answers
507 views

How do I pass a variable from my local server to a remote server?

I am trying to pass a variable from my local server (location1) to a remote server (location2). The purpose of the code is to copy a file from the remote server from a predefined location. In simpler ...
1
vote
1answer
33 views

Sourcing scripts with a for loop for different variables

I have several shell scripts that I summarised within a global script. I am using some variables that are the same across all scripts, and I wrote a separate script for this, which I am sourcing in ...
21
votes
3answers
880 views

If processes inherit the parent's environment, why do we need export?

I read here that the purpose of export in a shell is to make the variable available to sub-processes started from the shell. However, I have also read here and here that "Processes inherit their ...
3
votes
1answer
127 views

Difference between “.” and “./” while setting the environment variables using export? [duplicate]

Please excuse me if I am not clear while asking questions. I will try my best to be very clear while asking questions. While learning Embedded Linux, we are setting an environment for our project. ...
1
vote
0answers
67 views

Create global enviromental variable after boot

I know about /etc/profile and /etc/environment, but I would like to set a global environmental variable after boot and login. By global, I mean an environment variable that can be accessed by any ...
1
vote
2answers
230 views

Variable value is not recognized after using gnu parallel?

I have a below shell script from which I am trying to copy 5 files in parallel. I am running my below shell script on machineA which tries to copy the file from machineB and machineC. If the file is ...
3
votes
2answers
80 views

What environment and credential is used by startup, background and service processes

Startup scripts (on boot) Processes running in (or sent to) the background (when using SSH -fN for example) Services etc... What $path variable will they be using? What credentials? Anything else I ...
18
votes
5answers
1k views

why is setting a variable before a command legal in bash?

I've just encountered several answers such as to parsing a delimited text file... that use the construct: while IFS=, read xx yy zz;do echo $xx $yy $zz done < input_file where the IFS ...
4
votes
1answer
775 views

System environment variables not appearing in sudo

I have the following line my /etc/environment file: BROKER_URL=tcp://xxx.30.8.163:61616 I run this and get: $ set|grep BROKER_URL BROKER_URL=tcp://xxx.30.8.163:61616 Then, I run: $ sudo bash # ...
17
votes
7answers
720 views

How do I source another process's environment variables?

If I examine /proc/1/environ I can see a null-byte-delimited string of process 1's environment variables. I'd like to bring these variables into my current environment. Is there an easy way to do ...
3
votes
1answer
179 views

Set environment inside `nsenter /bin/bash`

I'm entering a namespace with nsenter -m -u -i -n -p -t $PID /bin/bash. However, printenv inside this namespace doesn't have everything I need. I'd like to send these variables in, but I'd like to ...
3
votes
2answers
92 views

184 environment variables too many?

I am trying to find the cause of some OS wonkiness, and am concerned about environment variables. The software I have been handed puts an incredibly high amount of environment variables into the ...
1
vote
1answer
220 views

Is the $HOME environment variable always set on a Linux system?

Assuming the machine is running a Linux kernel, sessions make use of the Bash shell and everything is using default configurations (no user has made any changes to config files), can we assume that ...
2
votes
2answers
452 views

What is the difference between env and printenv?

What is the difference between these two commands (env, printenv), which both shows the environment variables? They output same contents by default except '_'. And any historical reasons for two ...
6
votes
3answers
368 views

Understanding environmental variables in different contexts

Trying to understand the behaviour of the environment in Linux (Ubuntu 13.04 concretely), I've find different situations where setting envirionment variables are used or defined for/in different ...
1
vote
0answers
63 views

Setting environment variables at runtime in KDE4

Is it possible to set an environment variable at runtime, affecting all the programs started from the DE after that point (Desktop Environment, in my case KDE4) (without rebooting)? I know it it ...
0
votes
2answers
96 views

How can I ensure that a custom environment variable is set before cron runs a task?

I recently experienced a logwatch issue that is fixed by running export DATE_MANIP=DM5. cron seems to forget this when I logout (presumably because it's not saved). Where can I add this custom ...
2
votes
4answers
1k views

bash script and local env variable namespace collision

I have a bash script with a variable called VAR_A I also have a local env variable called VAR_A The bash script calls the command: echo ${VAR_A} I am not able to change the variable in the script ...
1
vote
1answer
623 views

How can I set up environmental variables for www-data?

I asked a question on dba.se about how I can give my Perl CGI script the password it needs to access the MySQL database it needs to query. I have received only one answer but that one suggests I save ...
2
votes
3answers
305 views

setting environment variable as a function of another env variable [duplicate]

I would like to set an environment variable (that we'll call "TEST") to store the path to a sub-directory of my home directory : something like /home/myself/dir/. I would like to use the $HOME ...
2
votes
2answers
190 views

What does `env COLUMNS=%S ps …` do?

I have seen the syntax env COLUMNS=%sin shell scripts, e.g. see the line below from the Helm package in Emacs: env COLUMNS=%s ps -axo pid,user,pri,nice,ucomm,tty,start,vsz,%%cpu,%%mem,etime,command ...
4
votes
3answers
167 views

Why does export -p exclude $_ variable?

As far I know, there are 3 ways to see exported variables: $ export -p | wc -l 50 $ env | wc -l 51 $ printenv | wc -l 51 As you can see, export -p misses single variable. It's a $_ one: $ diff ...
9
votes
2answers
35k views

How to permanently set environmental variables

My variables are LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib ORACLE_HOME=/usr/lib/oracle/11.2/client64 How to save these variables permanently ?
1
vote
1answer
50 views

Who is setting http_proxy?

On an Ubuntu system with bash as the default shell for the interested user, the http_proxy environment variable is set to a specific value in a fresh GNOME Terminal. The .bashrc file for this user ...
4
votes
2answers
656 views

Using environment variabless in Tmux status bar shell commands

I am attempting to create a tmux status bar which shows three timezones: US Eastern Time :: UTC :: Central European Time. Using the TZ environment variable makes the date command show the time in a ...
2
votes
1answer
82 views

Where do I place commands to automatically be exported for all users?

I have an embedded platform running an Arago linux distribution. Right now the only "user" is root but there will eventually be others, but I don't know how many or what user IDs they will have. ...
0
votes
1answer
59 views

Permanent Environment Variable with # linux Ubuntu

I am trying to set some environment variables permanently by editing the /etc/environment file. One of my environment variables has a "#" in it and some text after the "#". Everything after the "#" ...
0
votes
1answer
223 views

How to specify a custom include directory in Debian?

I am trying to compile my program on a Debian system via ssh and without root privileges. PRETTY_NAME="Debian GNU/Linux 7 (wheezy)" NAME="Debian GNU/Linux" VERSION_ID="7" VERSION="7 (wheezy)" I ...
1
vote
1answer
77 views

Restricting grep's --color option to the interactive shell

I have the following variable I want to set to make grep behave a certain way: GREP_OPTIONS=--color=always The problem is, I only want this environment variable to be set on the command line. I ...
1
vote
2answers
636 views

cd ${DIR_PATH} returns 'No such file or directory'

OS = MacOS 10.8.5/Darwin Kernel Version 12.5.0. In my .bash_profile I have: export DIR_PATH=~/concrete/path At the terminal >echo ${DIR_PATH} ~/concrete/path Also explicit cd works: ...
3
votes
2answers
396 views

How can I make shell aliases available when shelling out from Vim?

In my .zshrc, I declare some aliases. Eg, which dbstart shows the contents of that alias. If I open vim from that shell, it is a child process. In Vim, I can run shell commands with :! some_command. ...
1
vote
1answer
84 views

$@ and 'set env $PATH' - Why should this statement go into .inputrc?

I have a line in my .zshrc that says: set env $PATH Apparently this affects the value of $@. I have read that $@ should be empty and that I should not have any set statements in my .zshrc (at least ...
6
votes
2answers
1k views

Local variables in zsh: what is the equivalent of bash's “export -n” in zsh

I'm trying to contain the scope of a variable to a shell, and not have children see it, in zsh. For example, I type this in .zshrc: GREP_OPTIONS=--color=always But if I run a shell script with the ...
1
vote
2answers
88 views

Environment variable for command called via nice

I need to set an environment variable for a command that is being called via nice. [Bash and dash, Slackware and FreeBSD.] $ JIM=20 nice -n 10 echo $JIM $ Nope, echo can't see JIM $ nice -n ...
3
votes
1answer
37 views

How to read value of variable, where the name of variable is the value of another variable

I think an example is in order. Consider I have these two environment variables setup (by a Continuous Delivery tool): PACKAGE_VER=1.2.3 and USE_VERSION_FROM=PACKAGE_VER. What I want now is a script ...
2
votes
1answer
193 views

How to set environment variables under MATE?

I have just installed MATE under Ubuntu Saucy. No problems. Except I am trying to setup Texmaker, the LaTeX IDE, and cannot figure out how to set the paths to the LaTeX tools (pdflatex, etc.) which ...
1
vote
3answers
568 views

HowTo Chroot to BSD

I recently tried FreeBSD [9.2]. I installed it but as i found out it doesn't install any bootloader by default. So now i want to find out HOW it is possible to chroot to the installed BSD via a ...