I want to write an expect script which can do some task and in the end change the directory and give control to the user. I tried using
spawn cd path\\to\\dir
To change the directory in an expect script, you don't need to use the keyword "spawn" it works without it. You may be a little confused, because in the terminal, in which you are executing the script, you will stay in the same directory, but the script changed the directory in which it is doing things.
I suppose you have spawned some command (like ssh, bash) and the spawned command is still running. Then at the end you can do like this:
send "cd /some/dir\r"
interact