• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 696
  • Last Modified:

passing F3 using expect in a telnet automation script

i am using expect in a shell script for automaion of telnet.i have passed keystrokes like CTRLd using their octal codes e.g.
set CTRLd "\004"
send "$CTRLd"
now i need to pass F3 in that script ,what code should i use for passing F3 ??
0
rohit2
Asked:
rohit2
  • 2
  • 2
  • 2
  • +1
2 Solutions
 
ahoffmannCommented:
best is you use xkeycaps to find out what keycode is actually send to the aplication when you hit F3, then try this keycode in expect
0
 
rohit2Author Commented:
thanx for guiding me.
using xmodmap,i have got the keycode for F3 as 69 and it's keysym is "0xffc0".what code should i use in the send statement of expect.please write it down for me.
0
 
bryanhCommented:
Expect provides a tty device, not a keyboard, to the application.  So Telnet wants a terminal control sequence, not a keycode, from Expect.

The terminal control sequence for F3 varies from one terminal type to the next, so the code you want depends on what the application on the other end of the wire thinks the terminal type is.  But lets assume you're automating something that you can do successfully with some regular human-operated tty.  Get on that tty and type "cat >f3sequence".  Then hit F3.  Then hit Ctl-D twice to signify EOF to 'cat'.  Now you have the control sequence for F3 in the file 'f3sequence'.  On my xterm, it is the three characters ESC-O-R.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
rohit2Author Commented:
thanx bryanh :

yes the terminal type on the other side is VT52, for which
contrl sequence for F3 is same as urs ESC-0-R,then how should i enclose this sequence in the "send " statement of expect,should i write something like:
send "ESC-0-R"
or in some other format,do tell.
0
 
bryanhCommented:
You understand that ESC-O-R is just a way of writing 3 ASCII characters, right?  The first is Escape, the second is O, and the third is R.  The ASCII code for Escape is 033 octal.

Since you know how to send one ASCII character (e.g. Control-D), you must know how to send three.

I don't know Expect syntax, but based on what you say works for Control-D, I'd say you can send F3 something like this:

set ESC "\033"
send "$ESC"
send "OR"

I also expect that Expect already has built in some easy way to say "ASCII Escape".  In some languages, ESC-O-R can be written as "\eOR" or "\033OR".  You could try those.
0
 
ahoffmannCommented:
agree with bryanh that you have to send terminal and not keykodes
as suggested, it should go like this:
  send "\033OR"
0
 
jmcgOwnerCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: bryanh {http:#8000754} & ahoffmann {http:#8004024}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now