Define Variables

Hi,

I just define the variable in script and use those script in another script but the variable not recognize.

test1.sh

   #!/bin/bash
   DB="test_db"
   USR="test_user"
   PWD="test_pwd"
   HST="24.254.87.12"

test2.sh

   #!/bin/bash
   ./test1.sh
   mysql -u $USR -p $PWD -h $HST $DB

To execute here got some error

./test2.sh
mysql: option '-h' requires an argument

Any work around to make it work?

Very strange, because when i put all together in one script it work. My purpose of putting into one script just to call more of my scripts those loaded variables in test1.sh.

Thanks in advanced!

Regards,
FSPalero

use . or source command

#!/bin/bash
. test.sh
mysql -u $USR -p $PWD -h $HST $DB


or


#!/bin/bash
source test.sh
mysql -u $USR -p $PWD -h $HST $DB

Hi itkamaraj,

Working now, you save my work.

Thank you very much/

Regards,
Ferdie