Find the answer to your Linux question:
Results 1 to 5 of 5
I'm hoping someone can help me - I've yet to find a "simple" guide to expect anywhere (and one would be appreciated). I've searched google, and I'm only getting very ...
  1. #1
    Just Joined!
    Join Date
    Mar 2008
    Posts
    26

    Using Expect to get cisco running configs

    I'm hoping someone can help me - I've yet to find a "simple" guide to expect anywhere (and one would be appreciated). I've searched google, and I'm only getting very vague clues as to what I'm doing.

    [scenario] Expect is being run from box1, telnetting to box2, and from there accessing the different routers (it needs to be this way because of the security set-up) to get their running config and exporting it to box1.

    [problem] I was expecting to use something like:
    send "show run conf\r"
    expect "prompt"
    set results $expect_out(buffer)
    puts $results
    (or even better output to a file), on the Cisco. But of course, all I got was my login to box2.

    So somehow, I need to export the buffer from box2's instance of expect to box1 (I think?!). I've seen examples of things that sound like they do this, but I have no idea what all the */r etc does.

    If anyone could give me a straightforward answer I would be indebted.

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    "expect" is such a common word. googling for it will give you a too-low signal to noise ratio. For such words, try googling for this instead:
    Code:
    expect tutorial
    That will narrow it down.

    In particular, try this result that I got on the very first google results page. It's the official web home for expect.

    It also has useful links elsewhither if you don't find the stuff there sufficient.

    If nobody else steps in with a more direct answer, I'll be back on Friday!

    Good luck!
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Just Joined!
    Join Date
    Mar 2008
    Posts
    26
    Heh, I was hoping you'd answer - after searching the forums you seem to be the most knowledgeable about expect.

    Turns out, I was just being dumb. I was spawning a telnet session on box2 rather than just sending "telnet [ip address]".

    I still currently need help exporting the output from the router into a file on box1, so if you could give me any pointers, that'd be great.

    Thanks for the link as well, but I've been there and it wasn't much use to me unfortunately.

  4. #4
    Just Joined!
    Join Date
    Mar 2008
    Posts
    26
    Hey, I've fixed it now so don't worry Thanks Bill!

  5. #5
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Glad to know it worked out!
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

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