-   Programming (
-   -   Expect script: how do i send function key F12 in an expect script (

alix123 11-19-2008 03:33 AM

Expect script: how do i send function key F12 in an expect script
I'am new to expect how do i send function key F12 in an expect script??

teknik 11-20-2008 01:07 PM

take a look at

When I followed the instructions for the "od -c" command, for F12, I got:

0000000 033  [  2  4  ~  \n

Therefore, the send command in Expect would be:

send "\033\[24~"

cityprince143 08-29-2013 11:21 PM

Help Expect script : sending F9
The link you provided seems to be down. I am having the same issue as "alix123",but mine is F9. I tried sending send "\033\[20~". But didn't work. Could you please help.

Thanks in advance


lpd738 08-30-2013 11:15 AM

Well Ashok, I think the original reply has a typo and that is the second '\'. '\' is an escape character so you don't need to escape the '[' character. I think that you'll find that "\033[20~" or "\033[24~" will suit you better. If you care to know, the 033 is the octal representation of the ASCII ESC character... \ sets it into octal or other modes, i.e. \x0A is hex for 0A or 10 decimal. \012 is the octal (base-8) representation of that ASCII character. Here's a code snippet from my server, it uses XTERM or LINUXCON so it's DIFFERENT codes for the function keys.


child.send("\033OP") #Sends an F1 key. If I need to do manually, I hit "ESC O P". This does the same.
child.send("\015") #Sends enter key.

Also, sendline sometimes doesn't work sending the enter key so two child.send's is needed.

Good luck ya'll!

P.S. the command od -c -w4 will do you well. Run it, hit a FN key and then enter and it will display the info from the second post!

cityprince143 09-01-2013 10:06 PM

Thank You
Thanks a lot lpd738

I manage to workaround it. But I will try your suggestions, because if it works that will be perfect :-)

All times are GMT -5. The time now is 04:25 AM.