Reputation: 31
I have 2 shell scripts. In the first script I have kept the main method. In the 2nd script I have placed all the variables needed for the method since they are too many. Actually the main method needs 8 variables to run, likewise I have some 10 sets of 8 variables. The main method in script1 has to run for every set of variables. My questions:
How to call these variables from script 2 to the main method in script 1 in order to execute the same? Can I try declaring each set of variables as a function and try to call inside script 1? How to do that?
Please help me with this. Thank you in advance.
Upvotes: 1
Views: 2153
Reputation: 2778
I had a similar issue.
Thanks to Vignesh I made the following changes that worked for me:
Originally the variables were localized w/in the __RequestLogin.sh script:
#!/bin/bash
# Loading Data
sh __RequestLogin.sh
sh __ExecuteScript.sh
This Updated script allowes access to these variables w/in __ExecuteScript.sh:
#!/bin/bash
# Loading Data
. __RequestLogin.sh
. __ExecuteScript.sh
Upvotes: 0
Reputation: 136
you can keep the common variables alone in one script, say var.sh and add
. var.sh #dot Space var.sh
in all the scripts where the variables are needed
Upvotes: 6