This is a continuation of a series of videos where I'm teaching you to become a better network engineer
and teaching you commands in the Cisco iOS that you may not have known about as we both disappear.
Please do me a favor.
Put a comment below this video and let me know when you've learned something.
So put a timestamp on the video.
So how far would did you get through the video before you learn something?
Which command did you learn?
If you've no commands that I haven't used or options that I haven't used, please add them below this
video so that we can all learn from one another.
I wish I knew everything, but I don't.
I'm just sharing some tips and tricks that I know.
But please also add your tips and tricks below this video because this is YouTube.
Please, would you subscribe to my YouTube channel?
Please, would you like this video?
If you find it useful and please click on the bell to get notifications when I post a new video.
In this video I'm going to show you some Linux commands that you can run on Cisco iOS that will hopefully
save you a lot of time and hopefully surprise you with what's possible on the Cisco iOS.
In this example, I'm running a Cisco router.
This is a traditional Cisco iOS.
In other words, classic Cisco iOS version 15 six to TI.
This is a viral image that's running within Genius three.
So on this router, what I'm going to do is enable shell processing full.
This allows me to run Linux commands directly on the Cisco iOS.
I could also just do it this way if I only want to run it for my current terminal and not enable it
globally on the router.
Have a look at the series of videos.
If you are not sure about what this command does, I've discussed it in previous videos so I won't go
through all the options here.
Now shell processing supports quite a few commands.
If I tap show shell functions, I can see that cat is supported as an example.
GREP is supported but not this option.
Interface print interfaces that match the argument.
I'm going to run a very basic scripture which is for x x in interface ethernet zero do echo done.
This is a very basic script.
Paste that directly into privilege mode.
Notice I see the interfaces on the router similar to show IP interface brief, but I'm only looking
at ethernet interfaces.
So again, that's the script that I ran.
I'll post all these scripts below this video, so don't worry.
Trying to copy this down.
Just get it from below the video.
That's showing me the interfaces on the router.
Now, that may not be that interesting.
So let's expand the script.
I'm going to say for x x in interface Ethernet do echo.
Echo is one of the shell functions available.
Notice over.
They echo arguments to the terminal.
So I'm going to basically echo something to the terminal.
Based on show interface include input errors.
So this is going to show me not just the interfaces, but it's also going to show me any input errors.
So this line input error CRC frame overrun ignored is displayed in the output.
So you may prefer doing that on a switch.
So here's my switch terminal shell to enable the shell.
Paste that in.
I see all the interfaces on the switch and now I can see input errors, CRC overruns, etc. So I'll
be able to see any errors on an interface by simply running a very basic two line script, if you like.
Now if you want more details, this is available in the Cisco iOS Shell Configuration Guide.
Again, I've covered some of this in separate videos where I talk about terminal shell versus enabling
this globally on a device.
But if you scroll down, they start talking about scripts that you can run.
So very basic script is echo.
Here is a string with x, y, z in it where x, y, z is a variable in my basic script.
This is my variable x x.
So that's used in multiple places.
Scrolling down a bit further.
We can use if statements we can use for loops.
So let's take a very basic for loop here.
Directly from the documentation.
On my switch I'll paste that in four x in one, two, three, four, five echo x.
So just print that out.
That's what we get.
One, two, three, four, five.
Not very interesting, but let's do something with this by using a loop.
With a break statement.
So I'll copy this exactly as it is.
And I'll paste that into switch and we get numbers one, two, three, up to ten.
Again, not that interesting.
But what I've done is I've taken this exact script and then I've enhanced it slightly to do something
useful.
So here's my script.
I've created a function which means that it's a command that I can run multiple times rather than just
pasting something into the CLI.
So at the moment on the switch, if I tap show run, that doesn't work.
It's actually trying to do a domain lookup here on that.
So I'll speed up the video to break that notice it's doing translating show run.
So no IP domain lookup.
If our top show run that command doesn't work it's trying to do domain lookup on that obviously show
run like that will do something to show space run but S-H or UN is not a valid command.
But what I can do is paste my script in.
So I've created this function called Show Run.
Literally pasting that script in that I've created.
Now if our top show run.
It's doing a whole bunch of stuff and actually let me edit that down.
What I've done here is create this function setting end to minus one, and while something is true,
do something end is equal to itself plus one.
So while end is less than or equal to three type show run interface gigabit is zero something.
I'll get rid of the show IP route because that just confuses the output.
So paste that back in again.
Show run.
What this command has done is it's running a show run interface on specific interfaces.
Notice gigabit is zero zero gigabit or zero one.
Gigabit is error two and gigabit is error three.
It's also printing out this number which came from our script, that echo.
Let's get rid of that.
So I'm basically creating a function here that does a show run of interfaces on the switch.
So show run first interface zero zero is then 0102, zero three and so forth.
So it's doing a show run on each interface, but you could type any command here.
I've just done show run, interface gigabit zero and then a number I could do show interface like that.
So rather than show run, do a show interface on individual interfaces.
So top that again, show run, there's the first interface.
There's the second interface.
Third interface.
Fourth interface and done.
Now there are more interfaces than that on the switch.
A whole bunch of interfaces are available in the switch.
But what I wanted to show you is that you can run Linux scripts directly on the Cisco iOS by simply
enabling shell processing full, either globally on the switch or just typing terminal shell.
This document on Cisco's website, which I'll link below, gives you more examples where you can do
like logical tests.
If this equals this, then echoes something.
There's a whole bunch of options that you can do.
This is actually one of the commands I've just shown you.
You can actually configure interfaces if you want to.
So as an example, set to the interface description to something.
Okay.
I don't want to turn this into a programming video because it'll get too long.
I just wanted to show you some basic scripts that you may find useful like this, showing all interface
errors, and then you can do basic or more complex scripting.
Okay, so I hope you found this video useful.
I hope you've learned something.
I'll continue creating additional videos showing you options in the Cisco iOS that perhaps you don't
know about.
That can make you a better network engineer.
Once again, if you don't mind, please subscribe to my YouTube channel.
Please like this video and please click on the bell to get notifications.
I'm David Bumble.
I want to wish you all the very best as we vote this.