gpt4 book ai didi

networking - 期望脚本箭头键

转载 作者:行者123 更新时间:2023-12-05 08:34:23 26 4
gpt4 key购买 nike

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

send -- "^[\[C"

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

while executing
"send -- "^[\[C"
expect eof
"
(file "script_auto.exp" line 38)

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

最佳答案

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

send "\033\[C"

更新:

为当前终端获取正确的 RIGHT ARROW 键的最安全方法(如在 $TERM 中)是使用 tput:

[bash] # v=$(tput cuf1)
[bash] # printf '%q\n' "$v"
$'\E[C'
[bash] #

要了解 cuf1 的含义,请搜索 terminfo 的手册页。 :)

关于networking - 期望脚本箭头键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27496136/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com