(Tcl/Expect) clear screen after exit
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
开发者_StackOverflow社区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
}
~~
}
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.
EDIT: 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.
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
精彩评论