Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

perl to cisco connection

Posted on 2013-12-21
1
Medium Priority
?
252 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
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

972 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