Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

script help - sending variable to a second script

SOLVED
Go to solution
Jeff Paciolla_2
Occasional Advisor

script help - sending variable to a second script

Help!
I have a script that runs whenever an interface down event happens. What I am trying to accomplish is after i have collected the variables from the event, i want to send those variables to a different script for processing. My reason behind this, is that the original script just keeps growing and growing with new if then else statements, so i am trying to make the management of the scripts easier. Here is an example

Script 1

ABC=$1
EFG=$2
if [ $ABC = 123 ] ; then
./execute/2nd script
else
exit 0
fi

Script 2

HIJ = $ABC (from the first script)

is this possible??

thanks
jeff
4 REPLIES
Jeff Paciolla_2
Occasional Advisor

Re: script help - sending variable to a second script

my apologies for putting this in the database section. If anybody knows how i can move this question to the general section please let me know.

thanks
jeff
James R. Ferguson
Acclaimed Contributor
Solution

Re: script help - sending variable to a second script

Hi Jeff:

This would work as coded if you *export* the 'ABC' variable in script-1. Your code would read:

ABC=$1
export ABC
...

Regards!

...JRF...
Sridhar Bhaskarla
Honored Contributor

Re: script help - sending variable to a second script

Hi,

Keep a . before you execute the second script and the variables set by the first script will be inherited by the second one.

. ./execute/2ndscript

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Jeff Paciolla_2
Occasional Advisor

Re: script help - sending variable to a second script

thanks - both ways worked