Operating System - HP-UX
1752664 Members
5628 Online
108788 Solutions
New Discussion юеВ

Re: 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 4
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