Questions tagged [environment-variables]
Environment variables are system-wide variables which share the same value. These variables are often parsed by the shell when executing commands, and are expanded into their appropriate variable. For example, this allows users to move file locations without needing to update hard-coded paths in scripts (they just have to update the environment variable).
1,299
questions
1
vote
1
answer
87
views
How do package installers make packages available anywhere without adding them to the Environment Variables' path?
Example1:
When I install a package using a package manager such as the JavaScript package manager npm, the package immediately becomes available to run from any directory on any terminal:
$ npm ...
1
vote
1
answer
430
views
Can environment variables be made immutable?
With the recent discovery of the Symbiote vulnerability, it is now apparent that we need a mitigation for LD_PRELOAD injection attacks and similar. One way we may be able to prevent this exploitation ...
0
votes
1
answer
1k
views
Windows-to-Windows SSH: Get remote environment variable
From a Windows 10 host I connect to a Windows 10 target machine via SSH to read one of its environment variables, say, %COMPUTERNAME%. OpenSSH is installed on both machines. The remote shell is cmd, ...
0
votes
1
answer
799
views
How do I start PowerShell from an environment variable?
I can start cmd.exe using the %COMSPEC% environment variable, what is the equivalent for PowerShell?
2
votes
1
answer
688
views
How can I make CMD load normal system commands by default? (command prompt / powershell)
Please see below screenshot, this is pretty much self explanatory. All default programs in System32 aren't being loaded and can't run unless I specify the exact directory and path of the program
...
0
votes
1
answer
3k
views
How to store the result of a subquery in a variable in cmd?
Here's my bat file:
@echo off
for /F "tokens=* delims=," %%a in ('type C:\LocalSecrets\Depolyment.csv ^| findstr "%DomainName%"') do call :parcsv %%a
goto :EOF
:parcsv
echo &...
2
votes
1
answer
8k
views
Setting user PATH environment variable on Windows 10 has no effect
I have a bizarre problem with setting my user PATH variable. C:\Program Files\ghcup\bin is the path to my executable that I want to add to my user PATH.
I have tried setx /M path "%PATH%;C:\...
0
votes
2
answers
417
views
How to find where the variable come from in a bash set command?
It happens I have some unwanted environment variable inside the set command output, and I can't get rid of these:
$ set
ALL_PROXY=socks://127.0.0.1:10010/
.... (lots of environment variables)
...
0
votes
1
answer
1k
views
WSL2 / wslg Windows Start menu app - where is the $PATH env pulled from?
I've compiled the latest gnu compiler (11.2) on Ubuntu 20.04.
In my~/.bashrc , the directory I have gcc/g++ installed in is pathed.
Now, I have compiled R in wsl2 using the gcc 11.2 compiler. Then I'...
0
votes
1
answer
928
views
Run script on windows startup with environment variable
Windows should run a script on startup that starts a DB based on an environment variable %SAPSYSTEMNAME%:
net start SYBSQL_%SAPSYSTEMNAME%
When i run this command in my cmd it works fine, however on ...
0
votes
2
answers
1k
views
bash loop trough variables
if i have a bunch of variables in bash:
foo_1="path/1"
foo_2="path/2"
foo_3="path/3"
foo_4="path/4"
foo_5="path/5"
They all start with foo_.
Is there ...
2
votes
1
answer
8k
views
ssh commands in cron jobs on remote server
It is known that cron and ssh-agent do not communicate and hence ssh commands cannot be trivially run under cron. There are solutions involving keychain etc that make it possible to do this. However ...
0
votes
2
answers
568
views
Erased System Path Variables
I was writing a batch file that was supposed to automatically set up a computer to receive "psexec" remote commads. Unluckly i didn't really pay attention to what i was writing and i wrote ...
6
votes
2
answers
5k
views
Assign result of conditional expression to environment variable
I'd like to store the result of a conditional expression in an environment variable.
I tried:
C=$([ "$A" = "$B" ])
but the value of $C after running that is an empty string.
I ...
2
votes
2
answers
4k
views
Batch script that should set a path variable breaks the string
Im trying to set a user-path variable via setx in a win-batch-script, but it keeps breaking.
The path that I enter...
setx path "%path%;%ProgramFiles%\Pseudocode\"
...leads to this:
Sadly, ...
3
votes
1
answer
4k
views
multiline environment variable in /etc/environment
Title says it all really. I'm trying to set an RSA private key in /etc/environment. Things I've tried include wrapping the variable in single and double quotes, add a backslash at the end of each line ...
1
vote
1
answer
3k
views
UEFI Variable Storage (removing /sys/firmware/efi dump files) when Kernel Variables CONFIG_EFIVAR_FS & CONFIG_EFI_VARS both =y as in Ubuntu 20.04
In the Arch Wiki I see that the two kernel variables CONFIG_EFIVAR_FS & CONFIG_EFI_VARS should be set =y and =n respectively. Arch says, "This option should be disabled to prevent any ...
1
vote
0
answers
644
views
overcoming the WARNING: The length of the extracted value is truncated to 1024 characters
I have read this solution but they all fall into the case of the path which is not my case.
Overcoming the 1024 character limit with setx
Basically I created and want to use my environment variable, ...
0
votes
0
answers
419
views
Adding a variable to the PATH variable not translating
I have a bunch of applications that I install using MDT packages.
One of the packages needs an entry to the PATH variable.
I would like to add a variable to the PATH variable. But this variable is not ...
2
votes
1
answer
764
views
Bash or zsh conditional patterns and variable expansions
Suppose I want to generate a filename based on some given variables.
track=01
title="Some title"
album="Some album"
echo ${track}. ${title} (${album})
-> 01. Some title (Some ...
1
vote
1
answer
1k
views
Zsh: Passing multiple arguments to command (ls) from a variable ($LS_OPTIONS)
I am trying to customize ls command adding arguments to $LS_OPTIONS
The ls alias and LS_OPTIONS are defined in the default config file:
export LS_OPTIONS='--color=auto'
...
alias ls='ls $LS_OPTIONS'
...
1
vote
1
answer
629
views
How to echo environment variable in variable in DOS
I am not sure if this question holds true but I am trying to get solution for my problem as below:
set var1=ABC
set otherevars=C:\temp2
set %var1%dfts=C:\temp\test
all works fine till above line but, ...
0
votes
0
answers
1k
views
I cannot change the environment variable of %APPDATA%
Long ago I changed the %APPDATA% default path from C:Users\Username\Appdata to D:Users\Username\Appdata (I don't remember how). Now my D: hardrive crash and is no longer operational. I tried going to ...
0
votes
1
answer
2k
views
Windows 10 will not let me do anything to the system Path environment variable. Can't add, edit, or delete
When I try to do anything to the Path environment variable for system such as edit, add, or remove and entries I get "This environment variable is too large. This dialog allows setting values up ...
0
votes
0
answers
209
views
Malformed windows path environment variable
I haven't been able to find any information about this but my path environment variable has multiple entries that seem to be malformed.
Any idea what would have caused this?
F:\dev\emsdk;
F:\dev\emsdk\...
2
votes
1
answer
988
views
PATH is not being refershed in VS Studio Power shell environment?
I have added MingGW to my path a couple of days ago and I have turned off my computer yet I find that the path has not been refreshed. I currently have a Windows 11 OS. I have to run this command ...
6
votes
1
answer
2k
views
Can the Windows %PROGRAMFILES(X86)% environment variable be accessed in Cygwin or Git Bash?
In Git Bash and Cygwin, I can easily access the Windows %PROGRAMFILES% environment variable:
$ echo $PROGRAMFILES
C:\Program Files
$ echo ${PROGRAMFILES}
C:\Program Files
However, due to the ...
0
votes
1
answer
769
views
Set Client IP Address of an RDP Session as an environmental variable
My company uses some software that runs on our terminal server and connects back to a peripheral I have locally connected to my client laptop. The software defines an HKEY_CURRENT_USER registry key ...
0
votes
0
answers
954
views
Ruby showing in $PATH for WSL2, but not available to run
I'm running WSL2. If I echo $PATH in the WSL2 terminal, I see
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:
/usr/local/games:/usr/lib/wsl/lib:
/mnt/c/Program Files/...
3
votes
2
answers
2k
views
TERM system environment variable not set - Windows 10
So by mistake I deleted a bunch of my environment variables...
The one I cannot make sense of is TERM, a system-variable. Is this supposed to refer to the windows terminal? What value should I set it ...
1
vote
0
answers
17
views
What does the start command actually do? [duplicate]
Suppose I want to launch a program from the cmd (or windows powershell). If i simply type the name of the executable of course nothing starts, as my shell does not know where to find the .exe that I ...
3
votes
1
answer
8k
views
Set a Windows environment variable from within Git Bash
Is it possible to set an actual Windows environment variable from within the Git Bash for example? I know that you can set environment variables via the Git Bash in general with e.g.
FOOBAR=foo; ...
1
vote
1
answer
121
views
Added some console programs to System PATH, Can't invoke them via the registry
I added C:\Tools\scripts\PATH to my System PATH. It contains a few different console applications that I use frequently.
When I run them from the command-line everything is fine. As an example:
...
1
vote
3
answers
57
views
Can i convert my code in a global enviroment variable?
I made this code to be able to easily move a directory between my SSD and HD and also output a timestamp in my robocopy log files easily, it worked so well that i want to turn my timestamp &z& ...
0
votes
0
answers
920
views
Typing echo %path% in cmd shows a path that I don't see on the edit environment variables menu
I have this path to Miniconda C:\Users\[username]\miniconda3\condabin that shows up as the first entry when I type echo %path% in my cmd.exe but upon trying to edit it through the system environment ...
0
votes
0
answers
51
views
Variables inside commands inside if statement
I do not understand why this does not work:
existing_user=$(ldapsearch -x -b "cn=group,ou=group2,dc=company,dc=com" -H ldap://127.0.0.1 -D "cn=admin,dc=company,dc=com" -w "...
0
votes
1
answer
239
views
Windows : launch .sh using environment variable
i'm trying on windows to launch my server from anywhere in my computer (start_server.sh).
Launching my file containing those line manually works fine (using GitCMD) (probably not the best, i'm of ...
-1
votes
3
answers
10k
views
How to get existing environment variable, change the value of it and display it after change with CMD command?
So, after discussing with Berend, I figured out that I need to explain myself better and that is what I'm going to do.
So, my mission is to write a windows batch script that will:
Display(print to ...
0
votes
2
answers
5k
views
How to call programs from cmd directly without adding their paths to PATH variable on windows?
Suppose I installed a new package with someProgram in it:
myNewPackageDir/bin/someProgram
If I want to accessing it from cmd using only its name (example: someProgram --option1 a --option2 b --option3 ...
1
vote
2
answers
1k
views
get a process's private environment variables in Windows using powershell
I have a process (testxx) running on my Database. Every time a user connects with the database the process will start separate session for. All processes include a private environment variable(Client-...
2
votes
2
answers
292
views
Finding an exe from any hard drive and setting it as a variable
I have a way to find an exe file from any drive without needing to play with %path%, but I need it set as a path-to-file variable, not just displayed.
for %i in (a b c d e f g h i j k l m n o p q r s ...
0
votes
0
answers
131
views
Use windows environment variables in docker-compose.yaml file
I would like my Windows Username available in my (Linux) container as $WINDOWS_USERNAME using docker-compose. But when I try accessing it with ${env:USERNAME}, I get this error:
ERROR: Invalid ...
0
votes
1
answer
731
views
Windows path variable contains wrong entry
I know that the resulting path is the concatenation of system + user variables. However, my resulting path contains an entry which I don't know where is coming from, and on top of that is malformed, ...
0
votes
0
answers
76
views
merging multiple system variables in Windows 10
Windows 10 system variables are typically path references. Is it possible to add multiple path references to a single variable? I have a lot of variables related to JAVA or ANDROIDSTUDIO and other ...
0
votes
1
answer
1k
views
$PATH editting does not work
I am using Ubuntu 64-bit on a VM and installed an app, added it to $PATH using export PATH=$PWD/bin:$PATH in my terminal (T1). Worked fine. Then i wanted to use the command in another terminal (T2) ...
0
votes
1
answer
676
views
Cannot access certain environment variables set in ssh_config
I've put together a batch script that provisions a development server:
@echo off
set mode=development
set ssh_port=22
set secure_ssh_port=4096
if "%mode%" == "development" (
...
1
vote
1
answer
551
views
Docker get a list of possible environment variables
Hello! After intensive research I decided to bring this question up to the community. I started learning docker & docker-compose not long ago.
My question is:
How can I get a list of the possible ...
1
vote
2
answers
709
views
SHELL environment variable keeps returning the value of default shell
I'm using a terminal emulator with bash as the default shell ,then printed the value of the environment variable SHELL to print the current shell and it did , but when i enter another shell i.e., ...
1
vote
1
answer
932
views
Windows Command Line Batch Variable Substring with WMIC Output not Truncating Properly
Using Windows Batch all I want to do is get the specified drive size in MB (by drive letter) and corresponding free space available for that drive stored in a variable as an integer to do some basic ...
0
votes
1
answer
217
views
pytorch installation conda vs pip import error (macOs)
Currently, I have pytorch installed from this, which appears to be from anaconda.
╰─ pip install torch torchvision
Requirement already satisfied: torch in /Users/PLEB/opt/anaconda3/envs/pytorch/lib/...