I have two scripts, in which script1 takes pre-fixed arguments as below(I'm using case, shift function to shift arguments and assign them as required) This is how I call script1 normally:
script1 --env [env] --db [db] --table [table] --location [location]
This is how I iterate through arguments in script1:
while [ "$#" -gt 0 ]
do
case "$1" in
--env | --environment)
shift
envie="$1"
;;
--db)
shift
db="$1"
;;
--table)
shift
table="$1"
;;
--tableLocation)
shift
tableLoc="$1"
;;
esac
shift
done
A table will be created here after the above code and I'm not specifying the code intentionally.
My second script calls the above script along with the parameters(dynamic) and I have trouble doing it. I'm trying it this way now. I'd like to invoke script1 and would like to consider the status if a table has been created or not( I think a return code would help here).
env=env1
db=database1
table=table1
tablelocation=tablelocation1
#call script1
`source script1 --env $env --db $db --table $table1 --tableLocation $tablelocation`
I'm seeing "command not found" error for this line(there are no syntax errors) Please let me know if there is a way to call script1 with prefixed arguments.
script1? Is the first line of what appears to bescript1actually a synopsis of how to use it? There are aspects of your question that aren't clear. The first script is missing the loop control. It isn't clear what you do with the inputs after you've finished the loop. Please read about how to create an MCVE (minimal reproducible example).-X--some-arg, where-Xis the prefix indicating that--some-argshould be passed through to your subprocess, but that doesn't appear to be the meaning in which you're using that phrase here.