Op and event scripts are powerful tools you can use to automate the operation of your router. Have you ever wished you had a way to script a CLI command on the router? Or that you could program your router to always run a particular CLI command when a particular event occurs? Op and event scripts can do these things and more.
In this chapter, we will focus on op scripts. However, much of this information will also help you work with event scripts, which we cover in Chapter 7.
Before diving into the way op scripts work, let’s take a moment to look at the big picture: what can you do with op and event scripts? To give you an idea, let’s look at some use cases.
Junos has a robust and useful CLI, with many, many commands to cover a variety of situations. Using the CLI, it is fairly easy to perform just about any action you desire. However, there are times when you could make things even easier if you were able to script command sequences.
Consider this example. Imagine your network has a monitoring
system that reports when a BGP session goes down. Your standard response
is to log in to the router, run
terse to find the interface that carries the session, and then
show interfaces extensive to look
at the details for that interface.
You could simplify this process by simply being able to run a
single command that automatically figures out which interface has the
destination and then runs
extensive for that ...