Capturing User Input - 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

Capturing User Input

Capturing User Input
Cisco Content Services Switch Administration Guide
8-26
To capture user input in a variable, use the input command. You can use this
command to create a script to assist users in setting up configuration files or
preparing a CSS in some predefined way. For example, enter:
! Ask the user for his/her full name
echo "What is your full name?"
input FULL_NAME
echo "Hello ${FULL_NAME}!"
In the example above, notice that the input command has a variable argument
called FULL_NAME. Notice that you do not need to set FULL_NAME prior to
the input command. The command creates the variable and fills it with the data
that the user supplies. Also, note that the user's input is terminated by a carriage
return.
A user can enter any alphanumeric characters. If a user presses only the Enter key
and does not type any characters, then the script creates the variable with a NULL
value. This allows you to test the user input to verify that the user typed
something. In the following example, the script continues to ask the user the same
question until the user types "y".
echo -n "\please enter the character 'y' to exit."
input DATA
while DATA "NEQ" "y"
echo -n "Please enter the character 'y' to exit: "
input DATA
echo "\n"
endbranch
In the example above, notice the use of the echo command with the -n parameter.
This allows you to prompt the user with a message without forcing a new line at
the end of the sentence so that the user's data appears on the same line as the echo
command output. In the echo command quoted string, you can embed "\n", a
C-programming style character that puts a line feed in the output to make it more
readable.
Chapter 8
Using the CSS Scripting Language
OL-5647-02

Advertisement

Table of Contents
loading

This manual is also suitable for:

11500 series

Table of Contents