Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send INSERT and F12 in expect script

Tags:

bash

unix

expect

I know that in order to send return in an expect script I do something like this:

send -- "\r"

What is the send command for the INSERT and F12 keys? I've looked online and cannot find it anywhere.

like image 837
methuselah Avatar asked May 29 '18 11:05

methuselah


Video Answer


1 Answers

I have to say the initially accepted answer is not correct because

  1. The real char sequence is not the same for different terminal types;
  2. send -- "[2~" is wrong because
    1. [ in Tcl has special meaning (command substitution) so it should be backslash-escaped;
    2. The ESC char (\E as in infocmp's output) is missing;

The correct way:

set kf12 [exec tput kf12]
set kins [exec tput kich1]
... ...
send $kf12

If you need to manually specify the TERM type, use tput -T:

  • -Ttype

    indicates the type of terminal. Normally this option is unnecessary, because the default is taken from the environment variable TERM. If -T is specified, then the shell variables LINES and COLUMNS will also be ignored.

For the magic strings kf12 and kich1, search in the terminfo manual page.

like image 96
pynexj Avatar answered Sep 27 '22 23:09

pynexj