Thursday, September 11, 2014

Scripting: A Great Tool on Your Networking Belt

As I wrote in the blog post, Learn Unix and Stand Out From The Rest, the biggest reason you write scripts is to automate tedious tasks. But what scripting languages should you learn?

Unix scripting languages

Graybeards are going to grumble at me for my opinion!  For learning Unix scripting I recommend whatever shell dialect you feel best suites you.   If that means you become an expert in bash instead of sh or tcsh, more power to you.  :-)  

Two other languages you should learn are sed and awk.  These two text processing programs are very popular in the Unix world.  Sed is for editing streams of text and is commonly used for substitution programs, replacing one block of text for another.  Awk is also a text processing program, but it can do other things that sed cannot, including automatically opening and closing files, reading records, and breaking records up into fields.

Windows scripting languages

For Windows, the latest technology is PowerShell.  I will admit I have never used PowerShell, but I have read many posts by Windows systems engineers and it has been a huge benefit to them.  If you are already comfortable writing in .NET then PowerShell is very easy to learn.

Other scripting languages

The other two most popular scripting languages for network engineers are Perl and Python. Both of these languages work on Unix and Windows.  Unlike plain shell scripting (in Unix), Perl and Python allow you to do other things that plain shell scripting cannot, like writing scripts to contact devices on your network.

Regular expressions

While learning any scripting language is important, you also need to understand how regular expressions (abbreviated regex or regexp) work.  Regular expressions are a sequence of characters that create a search pattern.  These search patterns are mainly used for pattern matching with strings, e.g.,"find and replace" operations.   You will use pattern matching for BGP AS-Path access lists.

Recommended reading


Learning the bash Shell: Unix Shell Programming by Cameron Newham

Mastering Regular Expressions by Jeffrey E. F. Friedl

sed & awk by Arnold Robbins

Web sites:

Cisco: Regular Expressions by

Linux Shell Scripting Tutorial (LSST) v2.0 by Vivek Gite

Sh - the Bourne Shell by Bruce Barnett

No comments:

Post a Comment