# Exec command before/during/after "expect"

**URL:** <https://forum.ansible.com/t/exec-command-before-during-after-expect/22868>\
**Category:** Ansible Project\
**Created:** [October 24, 2016, 2:16pm UTC](https://forum.ansible.com/t/exec-command-before-during-after-expect/22868 "2016-10-24T14:16:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benjamin\_Redling](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@Benjamin\_Redling](https://forum.ansible.com/u/Benjamin_Redling)\
**Post date:** [October 24, 2016, 2:16pm UTC](https://forum.ansible.com/t/exec-command-before-during-after-expect/22868/1 "2016-10-24T14:16:00Z")

</div>

Hi everybody,

I'm trying to script around an ugly installer that expects to run from a  
DVD. I copied the DVDs and mounted them as loop device.  
The problem I face is that after the first DVD finished and it outputs a  
line beginning with "Insert DVD 2..."  
(A software that typically gets installed on a lot of cluster nodes...  
even when you say "-silent" to the installer... yeah!)  
but I have to umount the first disc and mount the second one \_before  
sending a response\_.

Alternativly copying the content of the DVDs together doesn't work,  
because the installer seems to check for the presence of files of the  
first DVD -- or at least it outputs a warning it still found the first  
DVD. That's why I started the whole mount/umount hassle...

Do I need to wrap a expect script and use the command or shell module  
for that, or is there a more elegant way with ansible?  
\_Any\_ ideas welcome that enable non-interactive handling of that situation.

Regards,  
Benjamin
