期望脚本箭头键

Aar*_*n88 0 networking system-administration tcl expect

我不知道如何使用expect发送箭头键,因此我为所有箭头键生成了autoexpect脚本,并发现autoexpect为右箭头键生成了这个字符:

send -- "^[\[C"
Run Code Online (Sandbox Code Playgroud)

我在自定义脚本中使用了相同的发送命令,但出现以下错误:

while executing
"send -- "^[\[C"
expect eof
"
    (file "script_auto.exp" line 38)
Run Code Online (Sandbox Code Playgroud)

我到底该怎么做才能发送右箭头键。任何帮助,将不胜感激。

pyn*_*exj 5

"^[\[C"中的无效字符串Tcl^[应该ESC\033. 所以试试这个:

send "\033\[C"
Run Code Online (Sandbox Code Playgroud)

更新:

为当前终端(如$TERM)获取正确的右箭头键的最安全方法是使用tput

send "\033\[C"
Run Code Online (Sandbox Code Playgroud)

要知道什么cuf1意思,请查看 searchterminfo的手册页。:)