Passing Vars between scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing Vars between scripts
# 1  
Old 06-22-2006
Passing Vars between scripts

Im running a script that runs scripts within it self and i need to pass vars made in the original script to scripts run within it and the only way i can think to do it is right the string to a file and read the file in the script
# 2  
Old 06-22-2006
email me if you know anything

read the rules about email

Last edited by RTM; 06-22-2006 at 02:13 PM..
# 3  
Old 06-22-2006
In the original script, when calling another script:

var1="`hostname`"
/mydir/my-other-script $var1
# 4  
Old 06-22-2006
Maybe i can function

$. principal_script var1 var2 var3 ......
........................
. subscript1 $var1 $var3
.......................
. subscript2 "$@" #if you like to pass all var

Bye
# 5  
Old 06-23-2006
I the main script, export those variables you want others to see:
Code:
#this is main script
export VAR1="value_var1"
./script.sh

VAR1 will be available to ./script1.sh
(for bash)

Regards.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing parameters with spaces between scripts

I have 2 scripts. test.sh, which calls submit2.sh. One of the parameters contains space and is quoted. ((((./submit2.sh Group_1_2_AMS_DAILY_CORE_GRP03 AMS AMS_D 'DAILY REPORT PROCEDURES'; echo $?>&3) | tee 1.log >&4)3>&1) | (read xs; exit $xs)) 4>&1 echo parm 1 = $1 echo parm 2 = $2... (1 Reply)
Discussion started by: andyclam
1 Replies

2. Shell Programming and Scripting

Passing vars or params to function

How to pass the getopts processed variable "${@}" to a function? It contains a list of package names needed in various functions. Seems the issue I have is due to the order of the script, with the processed "${@}" falling after the unprossed "${@}". I've been manually parsing options in the... (3 Replies)
Discussion started by: Cody Learner
3 Replies

3. Shell Programming and Scripting

General question about passing variables among shell scripts

So this is something I've been wondering how to do for a while. Suppose I have two shell scripts a.sh and b.sh script a does some function and outputs to a varable $x . I would then like to take $x into the second function, b.sh, and do a function on it and create some output. So how do you pass... (3 Replies)
Discussion started by: viored
3 Replies

4. Shell Programming and Scripting

Passing variables between sub-scripts

I have written a program for some data analysis. It is gettin long. I would like to restructure it so that i can have a master file which controls multiple subscripts in order to make it easier to understand. I need to be able to define variables in the master script which are used by all three... (2 Replies)
Discussion started by: carlr
2 Replies

5. Shell Programming and Scripting

Passing Arguments in Shell Scripts

Hello everybody! First time posting here:) Right, I am trying to pass arguments in my shell scripts using $1, $2 and $3 etc using if else statement........ This is my shell script which is based on serching the google website #!/bin/sh wget -t1 -E -e robots=off - -awGet.log -T 200 -H... (47 Replies)
Discussion started by: kev_1234
47 Replies

6. Shell Programming and Scripting

Perl parameter passing between scripts

Hi All, I have two perl scripts say A.pl and B.pl. A.pl interacts with Database and pulllls around 20 column-variables, which needs to be used in B.pl . A.pl calls B.pl, I figured out that there exist a limit on number of arguments being passed as command line argument. A.pl writing to a... (3 Replies)
Discussion started by: coolbhai
3 Replies

7. Shell Programming and Scripting

[/bin/sh] passing parameters with quotes between 2 scripts

Hi, I have a first shell script (/bin/sh) that receives some paremeters. This is only an example (there are more parameters in fact and this one is among them): -header "This is a test" This script calls a secund shell script (/bin/sh) with the same parameters. But, quotes disappear as I would... (0 Replies)
Discussion started by: velo_love
0 Replies

8. Shell Programming and Scripting

Passing variables between scripts

Hi all. I need to pass a value from a script that runs in a sub-shell, back into the calling shell like below (or into script 2 directly): outer_script export param=value1 script1 $param (in script1: export param=value2) script2 $param ($param is now value1, not value2... (4 Replies)
Discussion started by: bbergstrom74
4 Replies

9. UNIX for Dummies Questions & Answers

Passing variables between scripts...

Hey all, I'm wondering how you pass variable's that are defined in one script to another script that's been called by that first script..... Best regards, Jaz (1 Reply)
Discussion started by: Jazmania
1 Replies

10. Shell Programming and Scripting

Passing and using arguments in Scripts.

I am new to scripting in AIX / UNIX. I have a script that runs 4 other scripts and I want to be able to pass in a agrument that I can check before I run the next script to see if the previous script finished with no errors. Can someone send me an example of this as I'm sure it's pretty easy to... (1 Reply)
Discussion started by: David.Vilmain
1 Replies
Login or Register to Ask a Question