maximus maximus - 1 year ago 235
Bash Question

How to change current work directory using expect script?

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

but i am still in the same directory.
Any leads on how to accomplish this using expect ?

Answer Source

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"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download