clarkwang/sexpect

[v2.3.7] interact -re PATTERN: detach upon matching a specified pattern

clarkwang opened this issue · 2 comments

  • I used to think this is not quite useful. Changed my idea recently when writing a script which needs to input password in an interactive way for security's sake.
  • The whole logic can be done in the client side. Don't complicate the server side.

A bit more background:
In a corporate env it's not appropriate to ask users to pass their corporate account's passwords in command line. After spawning a program, when it prompts for the password, enter interactive mode and ask users to input their password manually, then automatically exit interactive mode when matching a specified pattern, then continue running the rest of the script.

Will only support -re PATTERN:

sexpect interact [-nocase | -icase | -i] [-cstring | -cstr | -c] -re PATTERN

There are quite some issues if the interact -re PATTERN logic is implemented in client side.

  1. sexpect sp bash --norc
  2. sexpect s -cr 'echo {a..z} | tr -d " " '
  3. sexpect i -re abc
  4. sexpect ex -re def <== This is supposed to succeed.

Sounds like the logic has to be moved to the server side.