Using Command Line Arguments - Cisco 11503 - CSS Content Services Switch Administration Manual

Content services switch
Hide thumbs Also See for 11503 - CSS Content Services Switch:
Table of Contents

Advertisement

Chapter 8
Using the CSS Scripting Language

Using Command Line Arguments

OL-5647-02
The CLI allows a user to pass command line arguments as quoted text to a script
using the script play command (see
ARGS variable to access the command line arguments that a user passed to a
script.
To print out all the arguments that a user passed to a script, enter:
echo "You passed the arguments: ${ARGS}"
If you want to access each argument individually, you can use the ARGS variable
as an array, where each argument passed on the command line is separated by
spaces. For example, enter:
echo "Your first argument passed is: ${ARGS}[1]"
The script below (called NameScript) prints a user's first and last names. The
script requires that the user pass his/her first and last name (in that order) in
quoted text to the script. For example, enter:
!no echo
if ${ARGS}[#] "NEQ" "2"
echo "Usage: NameScript \'First_Name Last_Name\'"
exit script 1
endbranch
echo "First Name: ${ARGS}[1]"
echo "Last Name: ${ARGS}[2]"
exit script 0
This script first tests to see if the user passed any arguments. If the user did not
pass exactly two arguments, then the script prints usage information to the screen
and exits. If the user passed two arguments, the script assumes that the first
argument is the user's first name and the second argument is the user's last name.
Finally, the script prints the user's first name and last name to the screen.
For example, to play NameScript, enter:
script play NameScript "John Doe"
The output is:
First Name: John
Last Name: Doe
"Playing a
Script"). Use the special reserved
Cisco Content Services Switch Administration Guide
Using Command Line Arguments
8-27

Advertisement

Table of Contents
loading

This manual is also suitable for:

11500 series

Table of Contents