Looks like you're invoking your expect script like sh DirectoryChange.sh
. Clearly sh
is not the correct interpreter for an expect script.
- change the file extension: ".sh" is for shell scripts
- make sure it has execute permissions then launch it with
./DirectoryChange.exp
repository=$PWD"/subdirectory/"
is not how to assign variables in expect. remove this line and edit thecd
line tocd subdirectory
- you don't have to interact with scp, so change the last line to
expect eof