1

When I login to one of our servers I'm prompted with:

Please select the system to work with:
   1: system1 (user u1)
   2: system2 (user u1)
   3: system3 (user u2)

Enter your choice (1-3) [1]:

and I need to enter "1" before any command is to be executed, right after login. Can I automatically respond via fabric to such prompts? Other boxes could have login without prompt, so it's only one of the possible situations. Something like this is desired:

if prompt("Enter your choice (1-3) [1]:"):
  response("1")
run(command)

How can this be done? I read Interaction with remote programs, however didn't find any useful example. i'd prefer to use only fabric, not to involve another modules if it's possible.

mt3
  • 2,654
  • 4
  • 26
  • 29
DominiCane
  • 1,263
  • 3
  • 16
  • 29
  • Possible duplicate of [How to answer to prompts automatically with python fabric?](http://stackoverflow.com/questions/10479078/how-to-answer-to-prompts-automatically-with-python-fabric) – Breedly Feb 05 '17 at 15:10

1 Answers1

1

Seems, no way.

Possible solutions are following:

  1. Some command-line tools supports flag that suppresses prompts placing default values instead (if it's what you need).
  2. You can use autoexpect tool that was proposed as possible solution in this topic.
Community
  • 1
  • 1
Marboni
  • 2,399
  • 3
  • 25
  • 42