Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Announcement: Try the Ask AI chatbot for answers to your technical questions about Juniper products and solutions.

close
header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Automation Scripting User Guide
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

get-input() Function (SLAX and XSLT) and get_input() (Python)

date_range 30-May-23

Namespaces

content_copy zoom_out_map
http://xml.juniper.net/junos/commit-scripts/1.0
http://xml.libslax.org/slax

Python Syntax

content_copy zoom_out_map
input = jcs.get_input('string')

SLAX Syntax

content_copy zoom_out_map
var $input = prefix:get-input(string);

XSLT Syntax

content_copy zoom_out_map
<xsl:variable name="input" select="prefix:get-input(string)"/>

Description

Invoke a CLI prompt and wait for user input. The user input is defined as a string for subsequent use. If the script is run non-interactively, the function returns an empty value. This function cannot be used with commit or event scripts.

The prefix associated with the namespace URI should be defined in the prefix-to-namespace mapping in the style sheet.

Note:

If the jcs.get_input string argument includes a null character sequence (\0), Python automation scripts generate an Invalid number of arguments error.

Parameters

string

CLI prompt text.

Return Value

input

Text typed by the user and stored as a string. The return value will be empty if the script is run non-interactively.

Usage Examples

In the following SLAX example, the user is prompted to enter a login name. The user’s input is stored in the variable $username.

content_copy zoom_out_map
var $username = jcs:get-input("Enter login id: ");

In Python:

content_copy zoom_out_map
username = jcs.get_input("Enter login id: ")

Release Information

Function introduced in Junos OS Release 9.4.

Support for the slax namespace http://xml.libslax.org/slax added in Junos OS Release 12.2.

Support for Python added in Junos OS Release 16.1R1.

footer-navigation