The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 10-23-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by arunkumar_mca View Post
Is there is way to share a variable between scripts?
Variables, or rather environment variables, belong to processes, not scripts, scripts change them but they exist with the process.

If you execute a script with "#!/bin/sh" it starts a new process to run the script in, hence a new set of environment variables, children will inherit the parent's exported variables but not the other way round.

The alternative is to run a script using "source" or ".". The down side of this is the script language has to be the same and the error handling must be consistent.