expect module hangs

Hello

I have a config to copy config to a tftp server
but with the expect module
it just hangs no error
it logs it successful with telnet( I can see it in the logs) but does not copy ( I have tested it manually with ftp)
please tell me where I am going wrong

Probably due to an unexpected output? Also you might want to try the
telnet module to communicate directly.

It looks like you are trying with levels of responses, that is not supported.
prompt bellow is also called question as in the documentation.

- expect:
    command: tel...
    responses:
      prompt-1: answer-1
      prompt-2: answer-2
      prompt-3:
        - answer-3
        - answer-4
      prompt-4:
        - anser-5

When an prompt appears more than once you need a list of answers like prompt-3 about, the first time it sees prompt-3 expect will respond with answer-3, the nest time it sees prompt-3 it will respond with answer-4.
The prompt/question is regex, so all regex special character like ()? need to be escaped if you have those character in that in the prompt.

It you don't get it working with this you need to provide the complete output when you do this manually.

thanks

when I run this I also get error message after amending the yaml script

You can only have one command: in expect.

If command is a prompt its not correctly indented.
And one prompt can only be listed once, the different responses is a list to that prompt.

If you would like more help you _need_ to provide the complete output when you do this task manually, without it this is futile.

Hi,

I have just done this manually on the switch and it worked

User Access Verification
Username: admin
Password:
POD2_C3560#copy running-config ftp:
Address or name of remote host ? 10.241.11.237
Destination filename [pod2_c3560-confg]?
Writing pod2_c3560-confg !!
8063 bytes copied in 1.108 secs (7277 bytes/sec)
POD2_C3560#

Thanks

I think you forgot the exit at the end, so I included it.

   - name: run show command via Telnet using the expect module
     expect:
       command: telnet 10.101.250.12
       responses:
         Username: admin
         Password: xxxxx
         POD2_C3560#:
           - copy running-config ftp
           - exit
         Address or name of remote host \[\]\?: 10.241.11.237
         Destination filename \[.*\]\?: ''

The '' is the same as just pressing enter.
I have escaped ? with backslash since they are character with meaning in regex.
Since the prompt POD2_C3560# comes up two times this is a list with the responses.

Hi,

A big thanks you it worked

Very Much appreciated