Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-19-2008, 02:33 AM   #1
Registered: Nov 2004
Posts: 63

Rep: Reputation: 15
Question 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??

Last edited by alix123; 11-19-2008 at 02:36 AM.
Old 11-20-2008, 12:07 PM   #2
Registered: Jun 2006
Location: Winnipeg, Canada
Distribution: Slackware 12.1
Posts: 33

Rep: Reputation: 16
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~"
Old 08-29-2013, 10:21 PM   #3
LQ Newbie
Registered: Aug 2013
Posts: 2

Rep: Reputation: Disabled
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

Old 08-30-2013, 10:15 AM   #4
LQ Newbie
Registered: Aug 2013
Distribution: Ununtu
Posts: 1

Rep: Reputation: Disabled
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!

Last edited by lpd738; 08-30-2013 at 10:19 AM.
Old 09-01-2013, 09:06 PM   #5
LQ Newbie
Registered: Aug 2013
Posts: 2

Rep: Reputation: Disabled
Thumbs up 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 :-)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Expect Script coolest Programming 7 02-16-2009 03:59 PM
Any expect script experts john83reuben Programming 5 07-21-2008 05:21 AM
expect script output saltydog4791 Programming 1 05-27-2008 08:01 AM
Script... variables with expect? Manana Linux - Networking 1 01-19-2007 04:41 AM
CGI script problem: Send/Expect command echo on webpage rajatgarg Programming 2 07-11-2004 04:38 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:08 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration