Solved

perl to cisco connection

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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
hard perl script 16 168
Perl modules on linux ec2 3 131
Log File Creation with Header and Footer 17 187
Use Perl to Remove Large Quantity of Files Quickly 8 28
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…

751 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