Solved

perl to cisco connection

Posted on 2013-12-21
1
250 Views
Last Modified: 2014-01-07
I want to let the do that ssh commands to the my cisco device how should i do it with perl ?


login as: root
root@ password:
force.salay.com.tr>enable
Password:
force.salay.com.tr#configure terminal
force.salay.com.tr(conf)#ip route xx.xx.xx.xx 255.255.255.255 null 0

Open in new window

0
Comment
Question by:3XLcom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
Jordan Medlen earned 500 total points
ID: 39742586
While perl can do this, I use expect scripts to perform various tasks. These scripts allow for automating various tasks based on received information and so forth.

For instance, portion of a script that logs into a Cisco edge device and checks connectivity to it's gateway...

    /usr/bin/expect <<EOF > /dev/null
    set timeout 10

    spawn ssh -q -o StrictHostKeyChecking=no $id@$ipaddr

    # First time, expect prompt for adding to known_hosts.
    expect {
        "Are you sure you want to continue connecting *" {
        send "yes\n"
        expect "*assword: "
        send "$pass\n"
        }
        "*assword: " {
        send "$pass\n"
        }
    }

    expect "*>"
    send "en\r"
    expect "*assword: "
    send "$enpass\r"

    expect "*#"
    log_file /tmp/remote_ping-$checkip.txt
    send "ping $checkip\n"

    expect "*#"
    send "exit\n"

EOF

Open in new window


This can then be used within a bash or other script.

Google "expect examples for cisco devices" and you will find a great deal of information.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question