Get/Set environment variables in a different tty

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1















I'm using a tool (Autokey) that spawns in a new shell. Cool tool, but I want to pull info from my current shell.



Say I'm on pts/0 and I have a variable set: VAR1=yes. In another shell, I want to be able to read the variable from pts/0 and take action accordingly. Would also be nice to be able to set the variable. Any way to do either?



MORE INFO THAT YOU DON'T NEED TO READ (probably):
What I'm doing is creating a reliable way to set up my environment on ANY remote *nix box (AIX, RHEL, SuSE). With one key combo, I run bash, set -o settings, set EDITOR and VISUAL, etc.



NFS is not reliably available. I could change my profile but I can't change root's or I screw it up for the other admins. Essentially, I'm left with whatever I can do over ssh. And it works the way I have it - it's just not pretty. I'd prefer something interactive.



For my specific situation, I've considered saving the variable to a file. That works, as long as I'm local. If I ssh out, saving a file remotely doesn't work.



The tool uses Python so maybe there's a way in Python to read a variable from another shell. I doubt that Python would be able to if Bash can't.










share|improve this question
























  • Relating unix.stackexchange.com/a/8344/117549 unix.stackexchange.com/q/27555/117549 and unix.stackexchange.com/q/91282/117549

    – Jeff Schaller
    Jan 2 at 19:00











  • One approach is to set up your own profile the way you like it, then when you become root, you can source ~yourself/.bashrc

    – glenn jackman
    Jan 2 at 20:22












  • Good point - and with autokey I can source it with a single key combo. That's probably what I'll do. Still, I wonder if there is a way to modify environment variables in another shell. Probably not without hacking systemd - or maybe bash.

    – BrowncoatOkie
    Jan 3 at 13:41















1















I'm using a tool (Autokey) that spawns in a new shell. Cool tool, but I want to pull info from my current shell.



Say I'm on pts/0 and I have a variable set: VAR1=yes. In another shell, I want to be able to read the variable from pts/0 and take action accordingly. Would also be nice to be able to set the variable. Any way to do either?



MORE INFO THAT YOU DON'T NEED TO READ (probably):
What I'm doing is creating a reliable way to set up my environment on ANY remote *nix box (AIX, RHEL, SuSE). With one key combo, I run bash, set -o settings, set EDITOR and VISUAL, etc.



NFS is not reliably available. I could change my profile but I can't change root's or I screw it up for the other admins. Essentially, I'm left with whatever I can do over ssh. And it works the way I have it - it's just not pretty. I'd prefer something interactive.



For my specific situation, I've considered saving the variable to a file. That works, as long as I'm local. If I ssh out, saving a file remotely doesn't work.



The tool uses Python so maybe there's a way in Python to read a variable from another shell. I doubt that Python would be able to if Bash can't.










share|improve this question
























  • Relating unix.stackexchange.com/a/8344/117549 unix.stackexchange.com/q/27555/117549 and unix.stackexchange.com/q/91282/117549

    – Jeff Schaller
    Jan 2 at 19:00











  • One approach is to set up your own profile the way you like it, then when you become root, you can source ~yourself/.bashrc

    – glenn jackman
    Jan 2 at 20:22












  • Good point - and with autokey I can source it with a single key combo. That's probably what I'll do. Still, I wonder if there is a way to modify environment variables in another shell. Probably not without hacking systemd - or maybe bash.

    – BrowncoatOkie
    Jan 3 at 13:41













1












1








1








I'm using a tool (Autokey) that spawns in a new shell. Cool tool, but I want to pull info from my current shell.



Say I'm on pts/0 and I have a variable set: VAR1=yes. In another shell, I want to be able to read the variable from pts/0 and take action accordingly. Would also be nice to be able to set the variable. Any way to do either?



MORE INFO THAT YOU DON'T NEED TO READ (probably):
What I'm doing is creating a reliable way to set up my environment on ANY remote *nix box (AIX, RHEL, SuSE). With one key combo, I run bash, set -o settings, set EDITOR and VISUAL, etc.



NFS is not reliably available. I could change my profile but I can't change root's or I screw it up for the other admins. Essentially, I'm left with whatever I can do over ssh. And it works the way I have it - it's just not pretty. I'd prefer something interactive.



For my specific situation, I've considered saving the variable to a file. That works, as long as I'm local. If I ssh out, saving a file remotely doesn't work.



The tool uses Python so maybe there's a way in Python to read a variable from another shell. I doubt that Python would be able to if Bash can't.










share|improve this question
















I'm using a tool (Autokey) that spawns in a new shell. Cool tool, but I want to pull info from my current shell.



Say I'm on pts/0 and I have a variable set: VAR1=yes. In another shell, I want to be able to read the variable from pts/0 and take action accordingly. Would also be nice to be able to set the variable. Any way to do either?



MORE INFO THAT YOU DON'T NEED TO READ (probably):
What I'm doing is creating a reliable way to set up my environment on ANY remote *nix box (AIX, RHEL, SuSE). With one key combo, I run bash, set -o settings, set EDITOR and VISUAL, etc.



NFS is not reliably available. I could change my profile but I can't change root's or I screw it up for the other admins. Essentially, I'm left with whatever I can do over ssh. And it works the way I have it - it's just not pretty. I'd prefer something interactive.



For my specific situation, I've considered saving the variable to a file. That works, as long as I'm local. If I ssh out, saving a file remotely doesn't work.



The tool uses Python so maybe there's a way in Python to read a variable from another shell. I doubt that Python would be able to if Bash can't.







linux bash shell terminal aix






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 20:52









Rui F Ribeiro

39.5k1479132




39.5k1479132










asked Jan 2 at 17:39









BrowncoatOkieBrowncoatOkie

565




565












  • Relating unix.stackexchange.com/a/8344/117549 unix.stackexchange.com/q/27555/117549 and unix.stackexchange.com/q/91282/117549

    – Jeff Schaller
    Jan 2 at 19:00











  • One approach is to set up your own profile the way you like it, then when you become root, you can source ~yourself/.bashrc

    – glenn jackman
    Jan 2 at 20:22












  • Good point - and with autokey I can source it with a single key combo. That's probably what I'll do. Still, I wonder if there is a way to modify environment variables in another shell. Probably not without hacking systemd - or maybe bash.

    – BrowncoatOkie
    Jan 3 at 13:41

















  • Relating unix.stackexchange.com/a/8344/117549 unix.stackexchange.com/q/27555/117549 and unix.stackexchange.com/q/91282/117549

    – Jeff Schaller
    Jan 2 at 19:00











  • One approach is to set up your own profile the way you like it, then when you become root, you can source ~yourself/.bashrc

    – glenn jackman
    Jan 2 at 20:22












  • Good point - and with autokey I can source it with a single key combo. That's probably what I'll do. Still, I wonder if there is a way to modify environment variables in another shell. Probably not without hacking systemd - or maybe bash.

    – BrowncoatOkie
    Jan 3 at 13:41
















Relating unix.stackexchange.com/a/8344/117549 unix.stackexchange.com/q/27555/117549 and unix.stackexchange.com/q/91282/117549

– Jeff Schaller
Jan 2 at 19:00





Relating unix.stackexchange.com/a/8344/117549 unix.stackexchange.com/q/27555/117549 and unix.stackexchange.com/q/91282/117549

– Jeff Schaller
Jan 2 at 19:00













One approach is to set up your own profile the way you like it, then when you become root, you can source ~yourself/.bashrc

– glenn jackman
Jan 2 at 20:22






One approach is to set up your own profile the way you like it, then when you become root, you can source ~yourself/.bashrc

– glenn jackman
Jan 2 at 20:22














Good point - and with autokey I can source it with a single key combo. That's probably what I'll do. Still, I wonder if there is a way to modify environment variables in another shell. Probably not without hacking systemd - or maybe bash.

– BrowncoatOkie
Jan 3 at 13:41





Good point - and with autokey I can source it with a single key combo. That's probably what I'll do. Still, I wonder if there is a way to modify environment variables in another shell. Probably not without hacking systemd - or maybe bash.

– BrowncoatOkie
Jan 3 at 13:41










0






active

oldest

votes











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492055%2fget-set-environment-variables-in-a-different-tty%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492055%2fget-set-environment-variables-in-a-different-tty%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?