Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 157

How can I "source" expect script

$
0
0

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.

Viewing all articles
Browse latest Browse all 157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>