# expect model not working accoring to plan

**URL:** <https://forum.ansible.com/t/expect-model-not-working-accoring-to-plan/26943>\
**Category:** Ansible Project\
**Created:** [March 9, 2018, 11:43am UTC](https://forum.ansible.com/t/expect-model-not-working-accoring-to-plan/26943 "2018-03-09T11:43:04Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![DOkuwa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dokuwa/32/1471_2.png) [@DOkuwa](https://forum.ansible.com/u/DOkuwa)\
**Post date:** [March 9, 2018, 11:43am UTC](https://forum.ansible.com/t/expect-model-not-working-accoring-to-plan/26943/1 "2018-03-09T11:43:04Z")

</div>

Hi all,

It is me again with config on boxes  
I am using the expect module it is working but not doing what I want it to do  
This is the code

name: backup of juniper using expect  
hosts: juniper  
connection: local  
tasks:

- name: copy running config to ftp server  
expect:  
command: ssh [admin@10.101.250.41](mailto:admin@10.101.250.41)  
responses:  
Password: xxxxxx  
admin@POD1\_SRX210\>:
- file copy /config/juniper.conf.49.gz ftp://ansible@10.241.11.237/juniper.conf.49.gz  
Password for [ansible@10.241.11.237](mailto:ansible@10.241.11.237): yyyyy  
admin@POD1\_SRX210\>:
- exit

This is what I expect it to do (copy config to ftp server)

ansible@ansible-new:~$ ssh [admin@10.101.250.41](mailto:admin@10.101.250.41)  
Password:  
— JUNOS 12.1X46-D55.3 built 2016-07-08 18:46:54 UTC  
admin@POD1\_SRX210\> [...ansible@10.241.11.237](mailto:...ansible@10.241.11.237)/juniper.conf.49.gz  
Password for [ansible@10.241.11.237](mailto:ansible@10.241.11.237):  
ftp://ansible@10.241.11.237/juniper.conf.49.gz100% of 1035 B 549 kBps  
admin@POD1\_SRX210\>

outcome of script  
ansible@ansible-new:/etc/ansible$ ansible-playbook backup-juniper-expect.yml -vvv  
ansible-playbook 2.4.2.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/home/ansible/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/dist-packages/ansible  
executable location = /usr/bin/ansible-playbook  
python version = 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609]  
Using /etc/ansible/ansible.cfg as config file  
Parsed /etc/ansible/hosts inventory source with ini plugin  
[WARNING]: While constructing a mapping from /etc/ansible/backup-juniper-  
expect.yml, line 12, column 9, found a duplicate dict key (admin@POD1\_SRX210\>).  
Using last defined value only.

PLAYBOOK: backup-juniper-expect.yml \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
1 plays in backup-juniper-expect.yml  
PLAY [backup of juniper using expect] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/system/setup.py  
\<10.201.250.41\> ESTABLISH LOCAL CONNECTION FOR USER: ansible  
\<10.201.250.41\> EXEC /bin/sh -c ‘echo ~ && sleep 0’  
\<10.201.250.41\> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “`echo /home/ansible/.ansible/tmp/ansible-tmp-1520595523.63-216576413530619`” && echo ansible-tmp-1520595523.63-216576413530619=“`echo /home/ansible/.ansible/tmp/ansible-tmp-1520595523.63-216576413530619`” ) && sleep 0’  
\<10.201.250.41\> PUT /tmp/tmpeyrq7Y TO /home/ansible/.ansible/tmp/ansible-tmp-1520595523.63-216576413530619/setup.py  
\<10.201.250.41\> EXEC /bin/sh -c ‘chmod u+x /home/ansible/.ansible/tmp/ansible-tmp-1520595523.63-216576413530619/ /home/ansible/.ansible/tmp/ansible-tmp-1520595523.63-216576413530619/setup.py && sleep 0’  
\<10.201.250.41\> EXEC /bin/sh -c ‘/usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1520595523.63-216576413530619/setup.py; rm -rf “/home/ansible/.ansible/tmp/ansible-tmp-1520595523.63-216576413530619/” \> /dev/null 2\>&1 && sleep 0’  
ok: [10.201.250.41]  
META: ran handlers  
TASK [copy running config to ftp server] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /etc/ansible/backup-juniper-expect.yml:8  
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/commands/expect.py  
\<10.201.250.41\> ESTABLISH LOCAL CONNECTION FOR USER: ansible  
\<10.201.250.41\> EXEC /bin/sh -c ‘echo ~ && sleep 0’  
\<10.201.250.41\> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “`echo /home/ansible/.ansible/tmp/ansible-tmp-1520595523.97-183325662742143`” && echo ansible-tmp-1520595523.97-183325662742143=“`echo /home/ansible/.ansible/tmp/ansible-tmp-1520595523.97-183325662742143`” ) && sleep 0’  
\<10.201.250.41\> PUT /tmp/tmpSdr\_De TO /home/ansible/.ansible/tmp/ansible-tmp-1520595523.97-183325662742143/expect.py  
\<10.201.250.41\> EXEC /bin/sh -c ‘chmod u+x /home/ansible/.ansible/tmp/ansible-tmp-1520595523.97-183325662742143/ /home/ansible/.ansible/tmp/ansible-tmp-1520595523.97-183325662742143/expect.py && sleep 0’  
\<10.201.250.41\> EXEC /bin/sh -c ‘/usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1520595523.97-183325662742143/expect.py; rm -rf “/home/ansible/.ansible/tmp/ansible-tmp-1520595523.97-183325662742143/” \> /dev/null 2\>&1 && sleep 0’  
changed: [10.201.250.41] =\> {  
“changed”: true,  
“cmd”: “ssh [admin@10.101.250.41](mailto:admin@10.101.250.41)”,  
“delta”: “0:00:02.954460”,  
“end”: “2018-03-09 11:38:47.026698”,  
“invocation”: {  
“module\_args”: {  
“chdir”: null,  
“command”: “ssh [admin@10.101.250.41](mailto:admin@10.101.250.41)”,  
“creates”: null,  
“echo”: false,  
“removes”: null,  
“responses”: {  
“Password”: “xxxxxx”,  
“Password for [ansible@10.241.11.237](mailto:ansible@10.241.11.237)”: “yyyyy”,  
“admin@POD1\_SRX210\>”: [  
“exit”  
]  
},  
“timeout”: 30  
}  
},  
“rc”: 0,  
“start”: “2018-03-09 11:38:44.072238”,  
“stdout”: “Password:\r\n— JUNOS 12.1X46-D55.3 built 2016-07-08 18:46:54 UTC\r\nadmin@POD1\_SRX210\> exit \r\n\r\nConnection to 10.101.250.41 closed.”,  
“stdout\_lines”: [  
“Password:”,  
“— JUNOS 12.1X46-D55.3 built 2016-07-08 18:46:54 UTC”,  
"admin@POD1\_SRX210\> exit ",  
“”,  
“Connection to 10.101.250.41 closed.”  
]  
}  
META: ran handlers  
META: ran handlers  
PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
10.201.250.41 : ok=2 changed=1 unreachable=0 failed=0

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 9, 2018, 12:03pm UTC](https://forum.ansible.com/t/expect-model-not-working-accoring-to-plan/26943/2 "2018-03-09T12:03:15Z")

</div>

You can only have one reposes with the same question/prompt, you have two of "admin@POD1\_SRX210\>" the last one will overwrite the fist one.  
So you need to merge them and have two list elements.

&nbsp;&nbsp;&nbsp;admin@POD1\_SRX210\>:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- file copy /config/juniper.conf.49.gz  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- exit

---

<div class="post-metadata">

**Author:** ![DOkuwa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dokuwa/32/1471_2.png) [@DOkuwa](https://forum.ansible.com/u/DOkuwa)\
**Post date:** [March 9, 2018, 12:37pm UTC](https://forum.ansible.com/t/expect-model-not-working-accoring-to-plan/26943/3 "2018-03-09T12:37:28Z")

</div>

Thanks

Changed code to this

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 9, 2018, 3:03pm UTC](https://forum.ansible.com/t/expect-model-not-working-accoring-to-plan/26943/4 "2018-03-09T15:03:06Z")

</div>

Need more detailed information, run  
ANSIBLE\_STDOUT\_CALLBACK=debug ansible-playbook -vvv \<your-playbook\> ...

---

<div class="post-metadata">

**Author:** ![DOkuwa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dokuwa/32/1471_2.png) [@DOkuwa](https://forum.ansible.com/u/DOkuwa)\
**Post date:** [March 9, 2018, 3:19pm UTC](https://forum.ansible.com/t/expect-model-not-working-accoring-to-plan/26943/5 "2018-03-09T15:19:37Z")

</div>

Thanks

This is the debug mode of the playbook

ansible@ansible-new:/etc/ansible$ ANSIBLE\_STDOUT\_CALLBACK=debug ansible-playbook -vvv backup-juniper-expect.yml  
ansible-playbook 2.4.2.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/home/ansible/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/dist-packages/ansible  
executable location = /usr/bin/ansible-playbook  
python version = 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609]  
Using /etc/ansible/ansible.cfg as config file  
Parsed /etc/ansible/hosts inventory source with ini plugin  
PLAYBOOK: backup-juniper-expect.yml \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
1 plays in backup-juniper-expect.yml  
PLAY [backup of juniper using expect] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/system/setup.py  
\<10.201.250.41\> ESTABLISH LOCAL CONNECTION FOR USER: ansible  
\<10.201.250.41\> EXEC /bin/sh -c ‘echo ~ && sleep 0’  
\<10.201.250.41\> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “`echo /home/ansible/.ansible/tmp/ansible-tmp-1520608575.06-81868420467920`” && echo ansible-tmp-1520608575.06-81868420467920=“`echo /home/ansible/.ansible/tmp/ansible-tmp-1520608575.06-81868420467920`” ) && sleep 0’  
\<10.201.250.41\> PUT /tmp/tmpa6lrDQ TO /home/ansible/.ansible/tmp/ansible-tmp-1520608575.06-81868420467920/setup.py  
\<10.201.250.41\> EXEC /bin/sh -c ‘chmod u+x /home/ansible/.ansible/tmp/ansible-tmp-1520608575.06-81868420467920/ /home/ansible/.ansible/tmp/ansible-tmp-1520608575.06-81868420467920/setup.py && sleep 0’  
\<10.201.250.41\> EXEC /bin/sh -c ‘/usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1520608575.06-81868420467920/setup.py; rm -rf “/home/ansible/.ansible/tmp/ansible-tmp-1520608575.06-81868420467920/” \> /dev/null 2\>&1 && sleep 0’  
ok: [10.201.250.41]  
META: ran handlers  
TASK [copy running config to ftp server] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /etc/ansible/backup-juniper-expect.yml:8  
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/commands/expect.py  
\<10.201.250.41\> ESTABLISH LOCAL CONNECTION FOR USER: ansible  
\<10.201.250.41\> EXEC /bin/sh -c ‘echo ~ && sleep 0’  
\<10.201.250.41\> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “`echo /home/ansible/.ansible/tmp/ansible-tmp-1520608575.4-159624176973195`” && echo ansible-tmp-1520608575.4-159624176973195=“`echo /home/ansible/.ansible/tmp/ansible-tmp-1520608575.4-159624176973195`” ) && sleep 0’  
\<10.201.250.41\> PUT /tmp/tmpFl10kg TO /home/ansible/.ansible/tmp/ansible-tmp-1520608575.4-159624176973195/expect.py  
\<10.201.250.41\> EXEC /bin/sh -c ‘chmod u+x /home/ansible/.ansible/tmp/ansible-tmp-1520608575.4-159624176973195/ /home/ansible/.ansible/tmp/ansible-tmp-1520608575.4-159624176973195/expect.py && sleep 0’  
\<10.201.250.41\> EXEC /bin/sh -c ‘/usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1520608575.4-159624176973195/expect.py; rm -rf “/home/ansible/.ansible/tmp/ansible-tmp-1520608575.4-159624176973195/” \> /dev/null 2\>&1 && sleep 0’  
The full traceback is:  
File “/tmp/ansible\_lyzE9I/ansible\_module\_expect.py”, line 109, in wrapped  
return next(resp\_gen)  
fatal: [10.201.250.41]: FAILED! =\> {  
“changed”: false,  
“invocation”: {  
“module\_args”: {  
“chdir”: null,  
“command”: “ssh [admin@10.101.250.41](mailto:admin@10.101.250.41)”,  
“creates”: null,  
“echo”: false,  
“removes”: null,  
“responses”: {  
“Password”: “xxxxxx”,  
“Password for [ansible@10.241.11.237](mailto:ansible@10.241.11.237)”: “yyyyy”,  
“admin@POD1\_SRX210\>”: [  
“file copy /config/juniper.conf.49.gz ftp://ansible@10.241.11.237/juniper.conf.49.gz”,  
“exit”  
]  
},  
“timeout”: 30  
}  
}  
}  
MSG:  
No remaining responses for ‘admin@POD1\_SRX210\>’, output was ’ …er.conf.49.gz fadmin@POD1\_SRX210\>‘.11.237/juniper.co  
[WARNING]: Could not create retry file ‘/etc/ansible/backup-juniper-  
expect.retry’. [Errno 13] Permission denied: u’/etc/ansible/backup-  
juniper-expect.retry’

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
10.201.250.41 : ok=1 changed=0 unreachable=0 failed=1

---

<div class="post-metadata">

**Author:** ![DOkuwa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dokuwa/32/1471_2.png) [@DOkuwa](https://forum.ansible.com/u/DOkuwa)\
**Post date:** [March 9, 2018, 3:28pm UTC](https://forum.ansible.com/t/expect-model-not-working-accoring-to-plan/26943/6 "2018-03-09T15:28:46Z")

</div>

This code works when I comment out the following in red

- name: backup of juniper using expect  
hosts: juniper  
connection: local  
tasks:
- name: copy running config to ftp server  
expect:  
command: ssh [admin@10.101.250.41](mailto:admin@10.101.250.41)  
responses:  
Password: xxxxxx  
admin@POD1\_SRX210\>:

# - file copy /config/juniper.conf.49.gz ftp://ansible@10.241.11.237/juniper.conf.49.gz

- exit

# Password for [ansible@10.241.11.237](mailto:ansible@10.241.11.237): yyyyyyy

outcome is  
changed: [10.201.250.41] =\> {  
“changed”: true,  
“cmd”: “ssh [admin@10.101.250.41](mailto:admin@10.101.250.41)”,  
“delta”: “0:00:02.905152”,  
“end”: “2018-03-09 15:22:42.046306”,  
“invocation”: {  
“module\_args”: {  
“chdir”: null,  
“command”: “ssh [admin@10.101.250.41](mailto:admin@10.101.250.41)”,  
“creates”: null,  
“echo”: false,  
“removes”: null,  
“responses”: {  
“Password”: “xxxxxx”,  
“admin@POD1\_SRX210\>”: [  
“exit”  
]  
},  
“timeout”: 30  
}  
},  
“rc”: 0,  
“start”: “2018-03-09 15:22:39.141154”,  
“stdout”: “Password:\r\n— JUNOS 12.1X46-D55.3 built 2016-07-08 18:46:54 UTC\r\nadmin@POD1\_SRX210\> exit \r\n\r\nConnection to 10.101.250.41 closed.”,  
“stdout\_lines”: [  
“Password:”,  
“— JUNOS 12.1X46-D55.3 built 2016-07-08 18:46:54 UTC”,  
"admin@POD1\_SRX210\> exit ",  
“”,  
“Connection to 10.101.250.41 closed.”

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 9, 2018, 3:38pm UTC](https://forum.ansible.com/t/expect-model-not-working-accoring-to-plan/26943/7 "2018-03-09T15:38:44Z")

</div>

I was hoping the -vvv would give some more information that this.

Since it's reporting No remaining responses for 'admin@POD1\_SRX210\>' could you add a few exit to the admin@POD1\_SRX210\> and try to run it again.

---

<div class="post-metadata">

**Author:** ![DOkuwa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dokuwa/32/1471_2.png) [@DOkuwa](https://forum.ansible.com/u/DOkuwa)\
**Post date:** [March 9, 2018, 3:59pm UTC](https://forum.ansible.com/t/expect-model-not-working-accoring-to-plan/26943/8 "2018-03-09T15:59:55Z")

</div>

Thanks

I added one more exit making it two exit at the same place and still error message

The full traceback is:  
File “/tmp/ansible\_BvrW7j/ansible\_module\_expect.py”, line 109, in wrapped  
return next(resp\_gen)  
fatal: [10.201.250.41]: FAILED! =\> {  
“changed”: false,  
“invocation”: {  
“module\_args”: {  
“chdir”: null,  
“command”: “ssh [admin@10.101.250.41](mailto:admin@10.101.250.41)”,  
“creates”: null,  
“echo”: false,  
“removes”: null,  
“responses”: {  
“Password”: “xxxxxx”,  
“Password for [ansible@10.241.11.237](mailto:ansible@10.241.11.237)”: “yyyyy”,  
“admin@POD1\_SRX210\>”: [  
“file copy /config/juniper.conf.49.gz ftp://ansible@10.241.11.237/juniper.conf.49.gz”,  
“exit”,  
“exit”  
]  
},  
“timeout”: 30  
}  
},  
“msg”: “No remaining responses for ‘admin@POD1\_SRX210\>’, output was ’ for [ansible@10.241.11.237](mailto:ansible@10.241.11.237):\r\nfetch: ftp://ansible@10.241.11.237/juniper.conf.49.gz: Not logged in\r\nerror: put-file failed\r\nerror: could not send local copy of file\r\n\r\nadmin@POD1\_SRX210\>'”  
}  
[WARNING]: Could not create retry file ‘/etc/ansible/backup-juniper-  
expect.retry’. [Errno 13] Permission denied: u’/etc/ansible/backup-  
juniper-expect.retry’

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
10.201.250.41 : ok=1 changed=0 unreachable=0 failed=1  
ansible@ansible-new:/etc/ansible$

Another issue is that manually after copying file before it exits  
it displays this message  
ftp://ansible@10.241.11.237/juniper.conf.49.gz100% of 1035 B 317 kBps  
I am not sure if this matters

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 9, 2018, 4:32pm UTC](https://forum.ansible.com/t/expect-model-not-working-accoring-to-plan/26943/9 "2018-03-09T16:32:49Z")

</div>

> Thanks
> 
> I added one more exit making it two exit at the same place and still error  
> message

I would suggest you add more exit to see if you get anywhere.

> &nbsp;&nbsp;&nbsp;&nbsp;"msg": "No remaining responses for 'admin@POD1\_SRX210\>', output was '  
> for ansible@10.241.11.237:\r\nfetch:  
> ftp://ansible@10.241.11.237/juniper.conf.49.gz: Not logged in\r\nerror:  
> put-file failed\r\nerror: could not send local copy of  
> file\r\n\r\nadmin@POD1\_SRX210\>'"

Now you have a message "Not logged in", maybe something goes wrong the second password entry.

> Another issue is that manually after copying file before it exits  
> it displays this message  
> ftp://ansible@10.241.11.237/juniper.conf.49.gz100% of 1035 B 317 kBps  
> I am not sure if this matters

I wouldn't think that it should cause any problems but it might since I think it the percentages is counting up.  
To overwrite the percentage on update it need to send some control characters like backspace to go back and overwrite, in you second output it showed a lot of \b maybe that's backspaces.

Is it possible to turn that output off?

---

<div class="post-metadata">

**Author:** ![DOkuwa](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dokuwa/32/1471_2.png) [@DOkuwa](https://forum.ansible.com/u/DOkuwa)\
**Post date:** [March 9, 2018, 4:51pm UTC](https://forum.ansible.com/t/expect-model-not-working-accoring-to-plan/26943/10 "2018-03-09T16:51:07Z")

</div>

Thanks

I am sorry not sure of how to write this backspace  
can you give an example please

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 10, 2018, 7:29pm UTC](https://forum.ansible.com/t/expect-model-not-working-accoring-to-plan/26943/11 "2018-03-10T19:29:12Z")

</div>

That is not what I tried to say, I was trying to explain what is happening and why it might fails.  
So I rephrase, maybe I become more understandable.

You said that Juniper write this line

&nbsp;&nbsp;&nbsp;ftp://ansible@10.241.11.237/juniper.conf.49.gz100% of 1035 B 317 kBps

I have never used Juniper, but I guess that the percentage is counting upwards from 0% to 100% on that line while the copying is in progress.  
For Juniper to do this one line it need to delete the 0% and write 10%, one way to do that is for Juniper to send backspace to the terminal to delete the text.  
When it has deleted 0% it can write out 10%, the it send more backspaces to delete 10% for so to write out 20% and so on to 100%.

The reason I think that Juniper might be doing this is the output you had

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"msg": "No remaining responses for 'admin@POD1\_SRX210\>', output was '  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...er.conf.49.gz ftp://ansible@10.24  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b1.11.237/juniper.co\radmin@POD1\_SRX210\>'"

\b is backspace, so Juniper at some point is sending backspace, probably to delete some text in the output.  
This might be a problem for expect, I have never used devices that sends backspaces to the console so I don't know.

Your best bet is to find a way to turn of the progress printing that Juniper is doing.
