My expect script:
#!/usr/bin/expect -f set timeout 1 spawn /opt/install.sh expect "\[input\] Are you installing the application at the central data center? \[yes/no default: yes\]? \[yes\]\r" send "yes\r" expect "\[input\] What is the code of central data center \[default: 01\]? \[01\]\r" send "01\r" expect "What is ip or hostname of your server \[default: localhost\]? \[localhost\]\r" send "portal\r" interact mkdir /opt/dir1 mkdir /opt/dir2 cp /root/file1 /opt/dir1
when I run this script by Ansible, after the end of the questions, script stops and won't run another command
mkdir /opt/dir1 etc.