Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a process I'm that I'm constantly having to deal with.

  • It requires I run a command and then enter several pieces of information.
  • Then I'm presented with a curses menu listing several options.

The first half is easy to automate using expect. The second part I don't know of an easy way to automate.

Any suggestions?

share|improve this question
up vote 1 down vote accepted

Unfortunately, expect (from any language) is not really suited to something that isn't a standard screen buffer response. I've seen some implementations that attempt to deal with cursor position updates such as curses but the results are not always effective.

I feel that your time would be better spent researching what operations the curses app is giving you a menu for configure your application do do those items yourself. I've found that nearly every curses menu has a companion cli cmd, or is a front end for one.

If you can share what the curses menu is for the community might be able to assist you with whats going on in the background. If you cant because it's something home grown, you should be able to trap whats going on in the background with something like strace

Hope this helps.

share|improve this answer
Thanks sadly the program I'm trying to work around is a partner companies software. We only have access to it by sshing into their box which launches the curses program. I don't have access to the box, or software. I do agree with you in general and in most cases I would be taking the path you suggest. – Tarrant Feb 27 '12 at 2:00
Thinking sideways, if the curses app is static( ie the option you want is always the third), you could always send the arrow key codes themselves and then your space and enter key. Its hokey, but should get you over the hump. – Xarses Feb 27 '12 at 2:29

Take a look at the hpuifilter utility included with RANCID. It was originally written to help RANCID's expect scripts deal with the curses-like menus of HP switches. However, it's written as a filter, so you can pipe your curses application into it, and it will spit out the plaintext stripped of VT100 control sequences, which should be easier to deal with in expect.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.