Anand Rao
Anand Rao

Reputation: 323

Send Enter key to Ansible expect responses

I'm using the expect module.

- name: "WAMUI Prerequisites Installer"
    expect:
    command: "./file.bin"
    responses:
            'PRESS \<ENTER\> TO CONTINUE:':'\n'

Would entering '\n' in the response send the Enter key?

Upvotes: 6

Views: 14519

Answers (1)

techraf
techraf

Reputation: 68629

Any string you provide as a response in the expect module will be terminated by the 0x0a. To simulate pressing just the Enter it's enough to define an empty string:

responses:
  'PRESS \<ENTER\> TO CONTINUE:': ''

Would entering '\n' in the response send the enter key?

It will send the n character followed by 0x0a.

You also need to fix indentation and spacing in the code you posted.

Upvotes: 12

Related Questions