New answers tagged

0

I'm about to ask this same question because I couldn't get the other answer example to work. However, I managed to achieve the working solution for me by using eval command. I'm not too sure why this wasn't posted earlier. do_something: $(eval export PATH=$(shell pwd)/bin:$(PATH)) @echo $(PATH) Note: the PATH changes is temporary within the ...


0

A "clean" bash environment may be had with $ env -i bash --noprofile --norc The env -i command executes the command given to it on the command line without transferring any of the exported environment variables of the old shell environment to the environment of the executed program. The --noprofile option stops bash from reading the system-wide or ...


0

While the accepted answer is correct, what you usually want to do is to: env -i bash -l -c "printenv; and any other commands" This gives you bare but functional bash (same as you'd get when login in non-interactive mode). This for example sets the language, timezone, HOME, etc.


1

After considering other options presented here, and not fully understanding how some of them worked I developed my own path_remove function, which I added to my .bashrc: function path_remove { # Delete path by parts so we can never accidentally remove sub paths PATH=${PATH//":$1:"/":"} # delete any instances in the middle PATH=${PATH/#"$1:"/} # delete ...


4

You can use eval: $ set -a $ eval "$(command_that_generate_output)" $ set +a $ sh -c 'printf "%s\n" "$DATABASE_URL"' someurl


0

I am using an installer which is adding entry of environment variable in bash_profile file, when i am starting jetty server, it was unable to find that entry..when i run source ~/.bash_profile it rerlaods the bash profle and server starts succesfully without any issues..The problem is customer is not going to start a new session nor he is going to manually ...


1

The source-code (runner.py) does this: term = os.environ.get('TERMCMD', os.environ.get('TERM')) if term not in get_executables(): term = 'x-terminal-emulator' if term not in get_executables(): term = 'xterm' if isinstance(action, str): action = term + ' -e ' + action else: ...


2

I recommend switching to a systemd based Linux distro, like Fedora or Ubuntu 16.04. systemd can easily pass environment variables to your process AND it can handle automatically restarting your process it fails as well as starting it at boot. Logging is also nicely handled by systemd`s journald. There's also not the overhead of installing or running ...


-1

Usually, when your cron tasks are run by root you need to set $HOME variable in your crontab or shell script. HOME=/absolute/path/to/your/application Then just run your script with relative path: * * * * * script.sh


0

There is clearly a syntax error in /etc/environment. Maybe a stray space, it's impossible to tell for sure from the error message alone. Just fix that error. You say you're setting PATH; the PATH=… line shouldn't have any spaces in it. The path separator is a colon :. The syntax of /etc/environment is just VARIABLE=VALUE, you can't use shell quoting there (/...


1

Enclose your alias in single quotes instead of double quotes. alias dockereval='eval $(docker-machine env)' Double quotes allow expansion of variable (in bash at least) while single quotes don't


2

You don't even need env here. In any Bourne-like shell (assuming the file is in sh syntax like in your example): (set -a; . ./e && ruby -e 'p ENV["a"]; p ENV["b"]') (set -a causes all future variable assignments to be exported to the environment). You could also do: cat e - << 'EOF' | paste -sd ' ' - | sh ruby -e 'p ENV["a"]; p ENV["b"]' ...


2

This is an example of not using the right tool for the job. env isn't the only tool that sets environment variables and then chain loads another program. And it doesn't read variable data from file. Of course, the . a.k.a. source command is not the right tool for this job, either. It permits the file to unexpectedly contain shell commands other than ...


-1

You need to find the code that is in error. This may help find ~ -maxdepth 1 -type f -print0 | xargs -0 grep 'PATH:home/pi/netkit/bin:/' find /etc -type f -print0 | xargs -0 grep 'PATH:home/pi/netkit/bin:/'


1

It is defined in an include-file read by the make program, e.g., by this line at the end of the port makefile: .include <bsd.port.mk> On my FreeBSD 10 system, the include-files are in /usr/ports/Mk, and grep finds these matches: $ fgrep -n PYTHON_REL * bsd.python.mk:70:# PYTHON_REL - Version number in numerical format, to ease bsd.python....


1

export PATH=$PATH:/whatever/you/want This will do what you meant :)


6

The shell checks for new mail after a command finished and $MAILCHECK or 600 seconds have passed. echo $! prints the PID of the last background process. After that, a check for mail may happen.


7

$! is the PID of the most recent background command. See this excellent answer for other special parameters.


5

$! is replaced by the process identifier of the last process placed in the background in the current shell, if any. The bash manual provides details of all such special parameters. To see this in action: echo $! should print 0 (assuming no jobs have been backgrounded) man bash & echo $! should print the process identifier of the man process which ...


1

Preserves pre existing ENV vars export $(shell [ ! -n "$(ENVFILE)" ] || cat $(ENVFILE) | grep -v \ --perl-regexp '^('$$(env | sed 's/=.*//'g | tr '\n' '|')')\=') test: echo $$FOO To run make ENVFILE=envfile test # bar export FOO=foo make ENVFILE=envfile test # foo


0

Some tools only accept EDITOR, for example the shell builtin fc: -e ENAME select which editor to use. Default is FCEDIT, then EDITOR, then vi


0

Every shell has a different way of sourcing environment variables (e.g., Is there a ".bashrc" equivalent file read by all shells?). For graphical programs which are started via the shell underlying the display manager, depending on how the display manager was started, the environment variables are set in different places (e.g., .xsession or ....


1

By default, .profile gets only loaded in login shells. Also by default, you don't get a login shell for a GUI shell. Either put it in e.g., .bashrc if you're in bash, or log out of your GUI sessions and then log back in. You can also source it manually (. "$HOME/.profile") or force a login shell with --login. I find it helpful to have echo statements in ...


0

I would just attach the new path export to the launcher directly. For example change the command in the launcher to export "PATH=$HOME/.bin:$PATH" ; geany %F You should be able to directly edit the launcher file for Geany in "/usr/share/applications/geany.desktop" this would have a more system wide effect for the application launcher. If you want all ...


0

Have you tried to hashbang the script_X with the path of the right interpreter(wrapper_script). #!/bin/wrapper_script (...blabla contents of script_X) where /bin is of course, the right path to the wrapper_script. With that will just need to: chmod +x script_X ./script_X This can solve your problem?



Top 50 recent answers are included