shell scripting – module which allows to use shell scripting int IOS command line.
This module helps automate routine actions and simplifies device management.
Can be used in conjunction with other management tools like EEM etc…
On most IOS platforms this feature was introduced on train 15. For catalyst 6500 starting from 15.1(1)SY

To enable shell CLI on the device you must run following command:

This will result in following output:

To disable Shell CLI:

This feature supports PATH variable which contains list of directories where shell can search for function/applets.
Also shell CLI supports following features:

1. Pipes and redirection

2. Embedded applets contains several built-in applets that help to create apps and filters for the user functions:

[[ evaluate a logical test expression
cat output data from a pipe or file to the terminal
cut edit piped output
echo echo arguments to the terminal
false return false in while or if expressions, and set the result
fetch return values from the configuration database
grep search for regular expressions in piped output or files
head print the first lines in the input
interface print interfaces that match the argument
let evaluate a numeric expression, and set the result
man print information for builtins
more page piped output to the terminal
nl number the lines in the input
null ignore the input
printf output formatted data to the terminal
read read input into variables
set_oper set operational values
sleep pause execution of the terminal
sort sort the input
tail print the tail of the input
true return true in while or if expressions, and set the result
uname print system information
wc count lines, words, and chars

3. Conditions – operator if….then….else

Following comparison operators can be used for working with integer values:

Operators Characteristics
-eq ==
-ne !=
-lt <
-gt >
-ge >=
-le =<

For working with files following conditions are available:

Operator Characteristics
-a or –e True if file exists
-d True if file exist and it is a directory
-f True if file exists and is a regular file
-r True if file exists and is readable
-s True if file exists and has a size greater than zero
-w True if file exists and is executable
-nt Test if file1 is newer than file2. The modification date on the file is used for this comparison
-ot Test if file1 is older than file2

To use several conditions in comparison you can use logical operators:

&& Logical AND
|| Logical OR

4. Loops Loops are same as in Linux shell – two operators are available: Operator “for”

And operator “while”


5. String operations

For string comparing if….then….else operator can be used with following modificators:

Simple shell script example:

Also we can see the list of functions that are predefined or created by user:

This entry was posted in Cisco, IOS and tagged , . Bookmark the permalink.