Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expect scripting

Status
Not open for further replies.

macrun95

Technical User
Dec 5, 2005
28
US
I hope someone out there is knowledgeable in expect scripting.

I'm trying to pass an escape code to the application. When the script gets to a SELECTION option I need it to pass a F2 which is mapped to ESCOQ on my keyboard. I tried just using the following:

expect {
timeout {failed "timeout at SELECTION\n"}
"SELECTION"
}
send -s "\033OQ"

That didn't work. I've been reading in the book about binding but am not sure that will work either or how to get the syntax correct.

Can anyone help with this? [ponder]

Much Thanks,

Eric
 
That seems to be the correct way to send an escape from expect... I just tested it to control an interactive vi session.

Are you certain that's the code that F2 is sending? What happens if you just run cat and hit F2, what text does it print?

Annihilannic.
 
I actually found out how to do it. I found a FAQ on expect's website. He suggested doing a 'od -c' at the command line and pressing the F2 key. It showed me what the key was mapped to and then I just had to put the backslashes in the right spot so it could interpret them correctly. I tested it and it worked. So I did the following:

send -s "\033\OQ"

That worked great.

Thanks for responding.

Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top