This post is more than 5 years old
5.7K Posts
0
5423
How to use a (Windows) CMD batchfile to run commands on Cisco MDS
I need to run some sort of script from a (Windows) host which runs 2 comamnds on the CLI of a Cisco MDS switch. Also: the output should be logged somewhere, preferrably to a log on that host.
Does anyone know how to do this? I want to fully automate it, so copy paste after starting an ssh session by using putty is not an option.
The commands I'm trying to run are:
show logging onboard | i "Module|FRAMES_DISCARD"
show interface counters | i "fc|B2B"
dynamox
20.4K Posts
0
April 2nd, 2014 08:00
give this command a try, i have a strong feeling it will work great
plink -ssh ip –l admin -pw password "show logging onboard | egrep Module|FRAMES_DISCARD"
cincystorage
467 Posts
1
April 2nd, 2014 10:00
You can actually generate and install an ssh key onto the cisco switch to eliminate the need for a password. Just create an public key file (NetBeans Help for netbeans.org Site Tools: Wiki: Winsshwithputty) and then make a user on the cisco switch and install the ssh key.
cont t
username dynamox password 0 role
username storagesvc sshkey
exit
Then you can ssh dynamox@switch and get in without a password. Great for scripts and automated process.
cincystorage
467 Posts
0
April 2nd, 2014 10:00
Your command to look at the b2b credits shows all interfaces, regardless of if they have active connections. Try the one below. It parses show flogi database to get a list of connections which have attached devices and show counters just for the active interfaces. Also it gets rid of the pesky more prompt.
show flogi database |inc fc |sed 's/ .*//' |sed -r -n 's/(.*)/show interface & counters | i "fc|B2B"/p' |vsh |no-mode
dynamox
20.4K Posts
1
April 2nd, 2014 12:00
when you connect using plink you never get prompted for "more", it's the same as if you were to use | no-more
ionthegeek
2K Posts
1
April 3rd, 2014 07:00
You may also want to take a look at TortoisePlink which is a modified version of plink that doesn't open up a console window. It's part of the TortoiseSVN project.
RRR
5.7K Posts
0
April 7th, 2014 02:00
plus that my first command almost always is "term len 0" anyway
cincystorage
467 Posts
0
April 7th, 2014 07:00
Good point.
You know me, I do a lot of automation.. I use a Perl module which creates an "interactive" ssh session, that way I can run commands and act on the output before doing the 2nd and 3rd step...
Best example is my script to active zone sets.. I check the number of active zones first, and make sure it matches...
But for these single command sessions, no need for " | no-mode"