(TCL /期待)退出后,画面清晰 [英] (Tcl/Expect) clear screen after exit
问题描述
我想从我的(半)互动expect脚本退出后清除屏幕(在本地计算机上)。我能做到这一点从脚本内?这是我尝试过,失败。
I want to clear the screen (on the local machine) after exiting from my (semi) interactive expect script. Can I do that from within the script? Here's what I tried, that failed.
#!/usr/bin/expect -f
set env(TERM) vt100
spawn ssh -Y username@domain
set user username
set pass password
#login sequence
expect "password: "
send "${pass}\r"
sleep .5
#some menu commands to enter ERP....
#...
#...
set CTRLZ \032
set CTRLC \003
set CTRLA \001
#don't time out
set timeout -1
interact {
-reset $CTRLZ {exec kill -STOP [pid]}
$CTRLA {
exp_send "menucmd...\ry\r"
}
$CTRLC {
#clear the host machine screen???
exec clear
exit
}
~~
}
在远程端我不是在shell,但在ERP项目。我可以退出的壳,然后在远程主机上做了一个明确的如果这就是必要的,但我想在远程主机提示仍然会在屏幕上。
On the remote side I'm not in a shell but in an ERP program. I could exit to the shell then do a "clear" on the remote host if that's what's necessary, but I think the remote host prompt would still be on the screen.
编辑:改为尝试退出之前清(子问题:EXEC清除运行脚本期待权的机器上执行)
changed to try clear before "exit" (sub-question: "exec clear" is executed on the machine running the expect script right?)
推荐答案
一旦[退出],一切之后是不会被执行。你应该[执行清]飞去。
Once you [exit], everything else after is not going to be executed. You should [exec clear] before exiting.
如果您使用的是VT100兼容终端(和大多数Unix终端),那么你可以尝试直接发送VT100命令到终端:
If you're using a vt100 compatible terminal (and most Unix terminals are) then you can try directly sending vt100 commands to the terminal:
puts \033\[2J
这篇关于(TCL /期待)退出后,画面清晰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!