It's my aim to make you the best network engineer that you can be.
In this video, I'm going to show you three ways to run scripts on Cisco Devices.
In other words, run them on box.
You don't need Python to run these scripting options.
They've been around in the Cisco iOS for many, many years.
I'm going to show you how to use Tickle or TCL scripts.
I'm going to show you how to use the embedded event manager and I'm going to show you how to use Linux
scripts directly on Cisco Devices.
Again, you don't need Python to run these scripts.
You don't need a separate VM or a separate shell.
You can run these directly on Cisco, iOS.
So in the same place where you type confetti or enable, you'll be able to run these scripts.
I want you to be the best network engineer in your organization.
I want you to go to interviews and blow away people with your knowledge and skills.
When a senior network engineer looks at what you're doing, surprise them with the knowledge that you
have.
Now a favor from you.
If you enjoy this video, please like it and please subscribe to my YouTube channel.
If you enjoy these videos, click on the bell to get notifications when I post a new video.
Now with that being said, let me show you how you can do really cool things on Cisco iOS devices.
In this example, I'm using three.
I'm not using a special version of Cisco iOS.
I'm just using traditional Cisco iOS devices here.
Okay.
So the first scripting option is using TICKLE or TCL scripts.
This document was updated in 2011.
In other words, this has been around for a long time.
The next one is the iOS embedded event manager.
This has also been around for a long time.
And then I'm going to show you the Cisco iOS shell.
I've shown you this in other videos, but I want to show you some scripting options using the Cisco
iOS shell.
Okay.
So let's start with Tickle or TCL.
Now you're going to run this in enable mode on a Cisco device.
In my gen three topology, he has rather one.
I've got about a two out of three.
These are all Cisco iOS V devices.
So if I type show version here, notice via iOS, this is the version of iOS.
There's nothing special about this.
This is just standard.
Cisco iOS.
Okay.
So TCL is notice the mode that we're in.
Whole bunch of commands are available here.
But what are we going to do?
Is we going to create a full loop?
So for each and you can call this anything IP address, a variable, whatever you like.
Notice the brackets.
So for each value here, we are going to ping the variable IP address.
So I'm going to copy that onto the Cisco device.
Now I don't need to be in this mode.
So I'm going to say tcl quit to quit out of tickle or TCL and I'm going to paste this in.
Notice what happens when I press enter now.
The router pings those four IP addresses in the list.
Now, this is a very basic script.
I mean, what I could do here is add a whole bunch of additional IP addresses.
But what I'll do is I'll simply add back duplicates of some of the IP addresses.
So I'll copy that.
Cut out of here and paste that in.
And that went very quickly.
But notice they have pasted the script in.
And what it's doing now is it's pinging every one of those IP addresses as well as the additional IP
addresses that I specified.
So it's TCL quit there now.
That's okay.
But you don't necessarily want to have to paste that in every time.
But if you're just doing some work on a device and you want to test IP connectivity to multiple devices,
you can do that.
A lot of CCI candidates use this for testing, connectivity and their CCI labs.
Now, what I've also got here is a Windows PC.
This is a Windows ten computer and I'm running the SolarWinds TFTP server on this computer.
You can download the SolarWinds TFTP server for free using the link below.
It's free software that you can download and use.
And what I've got here in the TFTP root directory is a typical script.
Okay, so here's our script.
I'll make the font a bit bigger so it's easier to read.
But essentially it's the same.
Option is we had before.
I've just got a tab between all the IP addresses.
So basically the same type of script.
But what I can do now is copy that to the flesh of the router.
So what's the IP address of this PC?
It's ten .1.1.101.
The name of the file is ping, dot, tickle or ping or TCL.
It's up to you which way you want to pronounce that.
So back on my router.
DA shows us that that file doesn't exist in flash.
Let's make sure that we can ping the TFTP server.
I can see a copy tftp flash ten 11101 is the TFTP server ip address ping tickle or ping tcl is the file
name.
I'm going to copy that to flash.
That's now copied across notice copied successfully.
D r shows us that that file is in flash.
What you can do now is simply use this command.
So.
TCL, S-H and the name of your script in flesh.
So on my router.
TCL.
S.H. You may want to do it this way.
I notice that you go or just do tcl's search and the name of the file in flesh.
And there you go once again.
So you could put a file like this in the flesh of a device.
You can actually call it directly from a TFTP server if you want to.
You don't have to run it in flash.
But I did in this example and notice that script now pings all the devices.
I could use more to look at my script.
So notice there's the script.
Once again.
All it's doing is running tcl's search for each IP address in this list here.
Notice the brackets once again.
It's going to ping the IP addresses in that list.
Okay.
So that's a very basic example of tickle or TCL.
If you want to get more information, have a look at this configuration guide.
I've put a link below this video if you want to have a look at this and get more information.
You can do various things with this, but I think the most useful basic options are the low hanging
fruit, as they would say, is to simply use it to ping multiple devices in your network.
Very basic script.
Okay.
So that's TCL or Tickle.
The next one is the Cisco iOS embedded event manager.
Let's have a look at that.
Once again, there's a lot of documentation on Cisco's website.
They've got links for real time network event detection and more writing policy using command line,
interface, etc..
But I'm going to show you a fairly simple example to get you started.
What I've got here is a script that says Event Manager Applet.
Give it a name.
So in this example, I'm looking for interface gigabit zero zero.
Going down.
Basically what it's doing is it's looking for the statement in syslog.
So it's looking for a syslog message like that as an example on my router.
If I go on to interface gigabit zero zero and I shut that interface.
Notice we'll see that statement in the output right over there.
Interface has gone down.
Now you could look for different events.
So OSPF neighbor relationship going down or something else happening.
You can use this to send you an email if something happens in your network.
I'm starting with a basic example here.
Let me know if you're interested in more detailed or more complex examples.
But basically what we're going to do is look for an event and then we've got a time period and different
actions.
Action, one, two, three, four, five and six.
And what are we going to do is run CLI commands.
Don't forget to use enable as your first command, then confetti.
Then we're going to go onto that interface.
Gigabit is zero zero and then we're going to shut it down and no, shut it.
And then we're going to write a syslog message saying Interface went down.
You could put any kind of message there that you wanted to, but let's copy that.
And again, I'll put the script below the video so that you can copy it and use it yourself.
You use all of these at your own risk, but I've tested this and I'll show you right now that it does
work.
So I'll go into global configuration mode and I'll paste that script in.
So notice in global config mode, event manager applet interface goes down.
Now notice what happens.
Interface gigabit is zero zero.
I'm going to shut it down.
So interface has gone down, but notice suddenly Interface has come up again.
Notice the special message here.
Gigabit zero zero went down and if I type do show IP interface, brief notice interface is up, up.
So show run.
Let's have a look at that running config.
Right at the bottom here.
Notice, here's my event manager.
I could change that as an example, I could say.
What's going on?
Gigabit.
Zero zero went down.
So let's do that.
Copy that.
In so global config mode.
Question mark will give you problems.
So let's do that manually and I'll show you another trick when it comes to question marks.
So let's do this.
Paste that in.
Press control the question mark.
Now I can actually add a question mark.
So on Cisco, iOS, if you need to add a question mark somewhere, use control v to allow you to edit.
So I'll paste the rest of that there and I should be in the right mode.
So event managers, my mode.
Let's paste that back.
It's accepted that.
And all I need to do is end my script.
Okay, so show IP interface.
Brief interface is currently up up.
But I'll go on to the interface and shut it.
So I've manually shut the interface down.
Notice we see our message.
What's going on?
Interface went down.
Notice interface goes down, but the interface comes up again.
Interface has come up.
Do show IP.
Interface brief interface is back to being up.
Up.
Okay.
We've also got debug.
So before I wrap this up, let's have a look at bugs.
So what I'll do is enable that debugging.
So M debugging is on.
Go onto the interface and shut it.
And hopefully what we'll see now is the commands will run and there you go.
So going up.
A lot of output.
Yeah.
Let's make that bigger.
Yeah.
Shut the interface down.
Notice the interface.
Change state to administratively down.
Sealy open was cold.
So the script was called.
Some of the information is displayed because we've opened up a timeline or a connection to the device.
You see this when you telnet or SSH to a Cisco iOS device.
But notice the important part is here out router one we sent the command enable out right a one privilege
mode.
We've sent the command config terminal.
This is what's displayed now we in global config mode we sent the command interface gigabit zero zero.
That's the mode.
We've shut the interface down, we've now shut the interface, we've displayed a message and the script
is now ended.
And now the interface has come up again.
So show IP interface brief.
Notice the interface is up up.
So basic example of a event manager applet showed you that with a debug.
So that was a very basic example of using the Cisco iOS embedded event manager.
It's one to get you started.
You can have a look at this document for more information.
There's plenty of options.
You could look for OSPF neighbor relationships going down and then you can get it to send you an email
as an example if you want to do that.
A lot of options available here, but that's a good one to get you started.
Okay.
The next one is the Cisco iOS Shell.
This allows you to use Linux commands directly on the Cisco iOS.
Here's a very basic one.
Four X in one, two, three.
Do something.
What are we going to do?
We're going to ping this variable X, which would be one, two or three, and then the script is done.
So let's try that on.
Writer one.
He has wrought a one again.
For this to work, I have to enable shell processing full so either globally on the road or switch or
I can do it on a per session basis by using that command.
So you don't need to do both.
This will just enable it on the local telnet or ssh h or console line until you finished.
In other words, till you exit out, then it'll stop running.
This enables the function all the time.
So basically this enables Linux commands on the right or switch.
So for X in 1 to 3, what are we going to do?
We're going to paying ten 11x done and notice it now pings those IP addresses.
So ping ten 111 ping ten 112 timed out there because of our and pinged ten 113.
So we've now pinged three IP addresses.
Now at the moment.
Show Shell functions shows us that there are no user defined functions, we've only got built in functions.
So both in functions are what's enabled when you type that command terminal shell as an example.
So we can do things such a show run grep face.
In other words, you use Linux commands directly on the Cisco iOS.
But what we can do is create our own user defined functions.
So what I'm going to do is paste that scripting.
Basically we've created a function called test ping.
Now if I remove that just to show you this, I'm going to remove that function.
And now when I try and use the command test ping, it doesn't work.
Command doesn't work.
But when I paste that in now and I use the command test ping notice it works because I've created this
user defined function.
Notice the brackets.
This is a function and what we're doing here is running four commands, so like pinging different devices.
Now you could do something like.
Function echo if you like, so just get it to echo something.
This is not doing much except printing stuff to the screen.
But the point is, is that you can create your own functions that can do things.
So notice now when I type test echo, it just echoes those values back doesn't really do anything.
Test ping is probably more valuable to us.
So show shell function now shows us that we've got these user defined functions.
Notice function test, echo function, test, ping.
So I think that's enough.
This video is getting really long, but that gives you an idea of what's possible using the Cisco iOS.
Remember, we didn't have to run Python here.
We didn't have to drop down to a Linux shell.
We didn't have to use a Linux VM.
We ran these commands directly on the Cisco iOS.
Go out there and show people how much you know, go and surprise them and amaze them with your knowledge
of the Cisco iOS.
I'm going to continue in the series teaching you options that not everyone knows so that you can be
a so-called boss on the Cisco iOS or like a really cool network engineer.
Now, please, if you've enjoyed this video, please like it and please subscribe to my YouTube channel.
Click on the bell to get notifications so that you know when to upload a new video.
I'm David Bumble.
I want to wish you all the very best.