faceless
faceless

Reputation: 488

bash: Dynamic cross-script variable's value update

I have 2 scripts: S1.sh and S2.sh.

S1.sh can run independently, and can receive positional value from "$1" as an optional parameter. This "$1" value is dynamic, and may be any number between 0 and 9.

VAL=$1

S2.sh is designed for remote triggering of S1.sh, and it uses its own "$1" (string value) for a different purposes.

I'm looking for a way to assign "$2" provided to S2.sh to $VAL of S1.sh.

Upvotes: 0

Views: 52

Answers (1)

chepner
chepner

Reputation: 531045

When S2.sh calls S1.sh, use

S1.sh "$2"

The value of S2's second parameter is passed as the first argument to S1.

Upvotes: 3

Related Questions