Saranya Sridharan
Saranya Sridharan

Reputation: 226

Expect timeout and return output without executing remaining commands

I am trying to run a shell script with ansible expect module which require 'n' number of response to be given, in one point I am giving a tar file name which need to be extracted by the script so it takes some time and then only i will be getting next prompt, But expect returns the output without waiting for it to complete and fails to run the commands that follows it. If it is happening because of timeout , is there any way to increase that ? Please help me resolve this issue. Thanks in advance.

Upvotes: 1

Views: 5920

Answers (1)

Andrew
Andrew

Reputation: 4632

To increase timeout when using expect module you should use timeout parameter, as described in this doc.

So if you want have a timeout of 300 seconds in example, shown in aforementioned doc, you'll end up with something like:

- name: Case insensitve password string match
  expect:
    command: passwd username
    responses:
      (?i)password: "MySekretPa$$word"
    timeout: 300 

Upvotes: 5

Related Questions