?
Solved

passing F3 using expect in a telnet automation script

Posted on 2003-02-19
8
Medium Priority
?
663 Views
Last Modified: 2010-08-05
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
Comment
Question by:rohit2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7987032
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
 

Author Comment

by:rohit2
ID: 7993687
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
 
LVL 5

Expert Comment

by:bryanh
ID: 7995021
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:rohit2
ID: 7998315
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
 
LVL 5

Accepted Solution

by:
bryanh earned 400 total points
ID: 8000754
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
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 400 total points
ID: 8004024
agree with bryanh that you have to send terminal and not keykodes
as suggested, it should go like this:
  send "\033OR"
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9983364
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 free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question