How to change current work directory using expect script?

南楼画角 提交于 2019-12-19 10:25:38

问题


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 interact

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


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/39720111/how-to-change-current-work-directory-using-expect-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!