Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A bash script is running as I defined it in Startup Applications. It is possible to display on terminal a variable used in that script? If yes, how?

share|improve this question
1  
You don't even tell us what kind of script? bash, Perl, Python? echo "$var"? – Hauke Laging Jun 8 '13 at 14:23
    
@HaukeLaging It's about a script bash. I tagged this thing. – Radu Rădeanu Jun 8 '13 at 14:42
    
It is rather unusual to use the tags for providing essential information rather than for a summary of the question's main topics... – Hauke Laging Jun 8 '13 at 14:52
up vote 2 down vote accepted

The quick answer (assuming this is a bash script as tagged) is no, variables are not shared between separate shell instances. The only way I know of to access a variable from a script started in a different shell is to have the script write the variable to a file and then access that file.

share|improve this answer
    
Have a look at /proc/$PID/environ and be happy. (Yes, that works for exported variables only.) – Hauke Laging Jun 8 '13 at 14:55
    
@HaukeLaging doesn't seem to work. I have a script running that contains export FOO=bar and cannot see FOO in /proc/$PID/environ` (I tried both the script's PID and the PID of the shell the script is running in). – terdon Jun 8 '13 at 15:08
    
Sorry, then I had a misunderstanding about how export works. Seems it becomes active after a fork / before an execve only. – Hauke Laging Jun 8 '13 at 15:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.