3

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.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
  • Relating https://unix.stackexchange.com/a/8344/117549 https://unix.stackexchange.com/q/27555/117549 and https://unix.stackexchange.com/q/91282/117549 – Jeff Schaller Jan 02 '19 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 02 '19 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 03 '19 at 13:41

0 Answers0