The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Accessing PL/SQL OUT variables in Korn Shell Script bright_future UNIX for Advanced & Expert Users 4 12-02-2008 12:02 PM
Accessing Shell Variables in awk or sed nasersh Shell Programming and Scripting 3 05-05-2008 08:44 AM
accessing shell script variable in file HIMANI UNIX for Dummies Questions & Answers 6 08-07-2007 12:07 AM
Accessing var from .profile into shell script videsh77 Shell Programming and Scripting 7 05-28-2005 01:21 PM
Accessing the home directory in shell script krishan SUN Solaris 1 05-21-2005 01:41 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-30-2007
rsendhilmani rsendhilmani is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 4
Accessing variables of one shell script in another shell script

Hi All,

I have a shell script called sample1.sh where I have 2 variables. Now I have another shell script called sample2.sh. I want the variables in sample1.sh to be available to sample2.sh.

For example. In sample1.sh I am finding the sum of 2 numbers namely a and b. Now I want to access these variables in sample2.sh. Is this possible? How can I do this?

Thanks in advance.
  #2 (permalink)  
Old 04-30-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Quote:
Originally Posted by rsendhilmani
Hi All,

I have a shell script called sample1.sh where I have 2 variables. Now I have another shell script called sample2.sh. I want the variables in sample1.sh to be available to sample2.sh.

For example. In sample1.sh I am finding the sum of 2 numbers namely a and b. Now I want to access these variables in sample2.sh. Is this possible? How can I do this?

Thanks in advance.
sample2.sh

Code:
. sample1.sh
.....

If you have only variables in sample1.sh, then you can use above code, else keep all the variables in one file and replace sample1.sh by that file name in above code.
  #3 (permalink)  
Old 03-17-2009
ultimatix ultimatix is offline
Registered User
  
 

Join Date: Oct 2008
Location: Mumbai
Posts: 55
Smile

export the variable u want to use

eg export var1

If value of var1 is set in 1.sh u can use the value of var1 in 2.sh
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:50 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0