O'Reilly logo

Automating Junos Administration by Stacy Smith, Jonathan Looney

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Op Scripts

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.

Use Cases

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.

Custom CLI Commands

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 show interfaces terse to find the interface that carries the session, and then run 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 show interfaces extensive for that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required