Junos Automation (Scripting)
Reply
Recognized Expert
Mattia
Posts: 198
Registered: ‎03-17-2010
0
Accepted Solution

Regular expressions in commit and op scripts

HI, I'm trying to implement a commit script which checks the format of an IP address. I know that JUNOS configuration commands support the use of regular expressions; is it possible to use regular expressions also in commit and operational scripts?

Thanks in advance for your help,

Mattia

.................................................................................
JNCIP-ENT, JNCIP-SEC, JNCIS-SP
(If this post helped you, please mark it as an "Accepted Solution"; kudos are also appreciated!)


Trusted Contributor
roy_lee
Posts: 28
Registered: ‎06-11-2008

Re: Regular expressions in commit and op scripts

You can use many of the standard unix-style regex expression in Junos automation scripts (commit/op/event).  Please take a look here for more detail:

http://www.juniper.net/techpubs/en_US/junos10.1/information-products/topic-collections/config-guide-...

 

There is also a parse-ip() extension function available for parsing IP address:

http://www.juniper.net/techpubs/en_US/junos10.0/information-products/topic-collections/config-guide-...

 

Here's an example script which makes use of parse-ip():

http://www.juniper.net/us/en/community/junos/script-automation/library/event/check-cli-acl/

 

Hope it helps.

Recognized Expert
Mattia
Posts: 198
Registered: ‎03-17-2010
0

Re: Regular expressions in commit and op scripts

Hi Roy, thanks for your feedback! I wasn't able to figure out the correct syntax to use (the matches statement seems to be supported only by configuration commands).

Looking into the links you suggested I found the jcs:regex() function, that's exaclty what I need!

 

.................................................................................
JNCIP-ENT, JNCIP-SEC, JNCIS-SP
(If this post helped you, please mark it as an "Accepted Solution"; kudos are also appreciated!)


Copyright© 1999-2013 Juniper Networks, Inc. All rights reserved.