0

Inside an script we are executing another script in the same directory which contain some variables definition:

SCRIPT1:

cd $configDir
script=PLS00170.sh
./config_fecha$script.sh

if [ ! -f /f_PL_50007622_Hist_Rel_Sico_Vta_Cp.$F1S4_FEOPERACA1 ]

config_fechaPLS00170.sh.sh:

#! /bin/ksh
#------------------------------------
#FEOPERAC
#------------------------------------
F1S4_FEOPERACA1=20150401
....

The Script 1 is not able to resolve the script $F1S4_FEOPERACA1:

Sysout:

...
+ ./config_fechaPLS00170.sh.sh
+ [ ! -f /f_PL_50007622_Hist_Rel_Sico_Vta_Cp. ]
...

Any idea?

1
  • Ugh. Why are you embedding data in the file name of the script, rather than just passing an argument? Commented Apr 8, 2015 at 15:17

1 Answer 1

3

You're executing the second script in its own process, so any variables defined there will be lost when it exits.

You could instead "source" the second script into the first one. This will run it as if the text was literally there. You can do that with

. ./config_fechaPLS00170.sh.sh    # note the first dot, then a space

or

source ./config_fechaPLS00170.sh.sh
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.