Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    copy configuration from tftp to router using expect

    i'm planning to do an automatic distribution of a configuration to a router,i decided to use expect script,telnet,and tftp to do that

    so i came up with this script on the internet and edit a few lines


    ## TomDV
    ## hxxp://blog.****]Using expect scripts to backup your Cisco configuration Penumbra

    # ---------------- configuration ---------------- #
    set device
    set tftp
    set user someuser
    set pass ultrasecret
    set config /tftpboot/config
    set position running-config
    set timeout 60

    # -------------- do not edit below -------------- #
    spawn telnet $device
    expect "Password:"
    send "$pass\n"
    expect ">"
    send "en\n"
    expect "Password:"
    send "$pass\n"

    send "copy tftp://$tftp/$config $posittion\n\n\n"
    expect "$tftp"
    send "\n"
    expect "$config"
    send "\n"
    expect "$position"
    send "\n"
    send "\n"
    send "exit\n"
    the script works fine for copying small configuration files,but when it's used to transfer a more complicated configuration the script failed,and on the router says "SYS-3-CONFIG_SYS_ERR failed to write"

    i'm guessing the problem here is because bigger configuration takes more time to transfer than smaller one,and the script sends "exit\n" before the transfer complete

    so is there any way to delay "exit\n" until the transfer completed?

    ps:sorry for the bad english

  2. #2

    Read my thread, it in few topics under you
    I did exactly what you want, just change the details to match your needs.

  3. #3
    hi meirh
    thanks for your reply, but i've already solved the problem
    the script fails because i didn't insert "expect #" so the script doesn't wait until the transfer completed,also i made some changes in time out variable to infinite by editing "set timeout -1"

    the end of the script should be like this

    expect "$position"
    send "\n"
    send "\n"
    expect "#"
    send "exit\n"


  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts