I'm forced to use a script like below:
# test.sh
function my_fun
{
echo "Give value for FOO"
local my_var
read my_var
export FOO=$my_var
}
# Call my_fun function
my_fun
by sourcing it from my shell.
$ source test.sh
Give value for FOO
stackexchange
$ echo $FOO
stackexchange
I would like to automate the script with expect like shown below:
$ expect test.exp
$ echo $FOO
stackexchange
The amount and names of the environmental variables in test.sh
is unknown.
Update:
- Added my_fun functionc all to test.sh.