I didn't know that how to send arrow keys using expect, hence I generated autoexpect script for all the arrow keys and found out that autoexpect generates this character for right arrow key:
send -- "^[\[C"
I used the same send command in my custom script and I'm getting a following error:
while executing
"send -- "^[\[C"
expect eof
"
(file "script_auto.exp" line 38)
What exactly shall I do to send the right arrow key. Any help would be appreciated.
"^[\[C" is an invalid string in Tcl. ^[ should be the ESC char which is \033. So try this:
send "\033\[C"
UPDATE:
The safest way to get the correct RIGHT ARROW key for current terminal (as in $TERM) is to use tput:
[bash] # v=$(tput cuf1)
[bash] # printf '%q\n' "$v"
$'\E[C'
[bash] #
To know what cuf1 means, run man terminfo and search for it. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With