Solved

perl to cisco connection

Posted on 2013-12-21
1
246 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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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