如何使用Expect脚本更改当前工作目录? [英] How to change current work directory using expect script?
本文介绍了如何使用Expect脚本更改当前工作目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想编写一个可以执行某些任务的Expect脚本,最后更改目录并控制用户.我尝试使用
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
spawn cd path\to\dir
interact
但是我仍然在同一个目录中. 任何有关如何使用Expect做到这一点的线索?
but i am still in the same directory. Any leads on how to accomplish this using expect ?
推荐答案
我想您已经 spawn 生成了一些命令(例如 ssh , bash ),并且 spawn ed命令仍在运行.然后最后您可以这样:
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
这篇关于如何使用Expect脚本更改当前工作目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文