0

Assuming we have a getopts shell library, "command_line.sh":

while getopts  “c:” argv

do
     case $argv in

         c)
             CLIENT_ID=$OPTARG


             ;;
     esac
done

echo "CLIENT_ID is ${CLIENT_ID}"

How can we pass the above ${CLIENT_ID} from the above shell library to another script without using export as an environment variables?? I have tried some solutions in the following link, but none of them works

Pass all variables from one shellscript to another?

For example:

#!/bin/sh

. ./command_line.sh -c 1

echo "CLIENT_ID is ${CLIENT_ID}"

or

#!/bin/sh

./command_line.sh -c 1

echo "CLIENT_ID is ${CLIENT_ID}"

or tried in bash instead of sh

sadly none of them works. Could any guru enlighten? Thanks.

Community
  • 1
  • 1
Chubaka
  • 2,933
  • 7
  • 43
  • 58

0 Answers0