How can we update a variable from one shell to another shell ?
Suppose , I am having 2 Putty sessions opened , I want to set a variable in the first SHELL and I need that variable to access from the 2nd SHELL .
Is is possible ?
How can we update a variable from one shell to another shell ?
Suppose , I am having 2 Putty sessions opened , I want to set a variable in the first SHELL and I need that variable to access from the 2nd SHELL .
Is is possible ?
As each process' environment is protected, there's no way to share environment variables. I would suggest using a file on a shared filesystem to store the variable you want and reading that file in whenever you'd need to know what the new value is.
You can save the variable to a script. Then source the script in the 2nd session.
For example:
It is usually not possible, because each shell (and each process) has its own environment. See execve(2).
However, you might want to switch to the
fish
shell. It gives you so called universal variables which might be shared between several instances of (i.e. processes running) thefish
shell. This is implemented thru the fishd user daemon (with which everyfish
process communicates).