Automation

last person joined: 3 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  Regular expressions in commit and op scripts

     
    Posted 03-22-2010 06:25

    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



  • 2.  RE: Regular expressions in commit and op scripts
    Best Answer

    Posted 03-22-2010 15:43

    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-automation/topic-40431.html#jd0e41429

     

    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-automation/extension-functions-overview.html#id-jcs-parse-ip

     

    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.



  • 3.  RE: Regular expressions in commit and op scripts

     
    Posted 03-23-2010 02:50

    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!