cisco ios shell command reference · shell environment load ... uname print system information...

22
Cisco IOS Shell Command Reference Americas Headquarters Cisco Systems, Inc. 170 West Tasman Drive San Jose, CA 95134-1706 USA http://www.cisco.com Tel: 408 526-4000 800 553-NETS (6387) Fax: 408 527-0883

Upload: ngohuong

Post on 26-Aug-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

Cisco IOS Shell Command Reference

Americas HeadquartersCisco Systems, Inc.170 West Tasman DriveSan Jose, CA 95134-1706USAhttp://www.cisco.comTel: 408 526-4000 800 553-NETS (6387)Fax: 408 527-0883

Page 2: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

THE SPECIFICATIONS AND INFORMATION REGARDING THE PRODUCTS IN THIS MANUAL ARE SUBJECT TO CHANGE WITHOUT NOTICE. ALL STATEMENTS,INFORMATION, AND RECOMMENDATIONS IN THIS MANUAL ARE BELIEVED TO BE ACCURATE BUT ARE PRESENTED WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED. USERS MUST TAKE FULL RESPONSIBILITY FOR THEIR APPLICATION OF ANY PRODUCTS.

THE SOFTWARE LICENSE AND LIMITEDWARRANTY FOR THE ACCOMPANYING PRODUCT ARE SET FORTH IN THE INFORMATION PACKET THAT SHIPPED WITHTHE PRODUCT AND ARE INCORPORATED HEREIN BY THIS REFERENCE. IF YOU ARE UNABLE TO LOCATE THE SOFTWARE LICENSE OR LIMITED WARRANTY,CONTACT YOUR CISCO REPRESENTATIVE FOR A COPY.

The Cisco implementation of TCP header compression is an adaptation of a program developed by the University of California, Berkeley (UCB) as part of UCB's public domain versionof the UNIX operating system. All rights reserved. Copyright © 1981, Regents of the University of California.

NOTWITHSTANDINGANYOTHERWARRANTYHEREIN, ALL DOCUMENT FILES AND SOFTWARE OF THESE SUPPLIERS ARE PROVIDED “AS IS"WITH ALL FAULTS.CISCO AND THE ABOVE-NAMED SUPPLIERS DISCLAIM ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THOSE OFMERCHANTABILITY, FITNESS FORA PARTICULAR PURPOSEANDNONINFRINGEMENTORARISING FROMACOURSEOFDEALING, USAGE, OR TRADE PRACTICE.

IN NO EVENT SHALL CISCO OR ITS SUPPLIERS BE LIABLE FOR ANY INDIRECT, SPECIAL, CONSEQUENTIAL, OR INCIDENTAL DAMAGES, INCLUDING, WITHOUTLIMITATION, LOST PROFITS OR LOSS OR DAMAGE TO DATA ARISING OUT OF THE USE OR INABILITY TO USE THIS MANUAL, EVEN IF CISCO OR ITS SUPPLIERSHAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Any Internet Protocol (IP) addresses and phone numbers used in this document are not intended to be actual addresses and phone numbers. Any examples, command display output, networktopology diagrams, and other figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses or phone numbers in illustrative content is unintentionaland coincidental.

Cisco and the Cisco logo are trademarks or registered trademarks of Cisco and/or its affiliates in the U.S. and other countries. To view a list of Cisco trademarks, go to this URL: https://www.cisco.com/go/trademarks. Third-party trademarks mentioned are the property of their respective owners. The use of the word partner does not imply a partnershiprelationship between Cisco and any other company. (1721R)

© 2018 Cisco Systems, Inc. All rights reserved.

Page 3: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

C O N T E N T S

C H A P T E R 1 A through Z Commands 1

shell environment load 2

shell environment save 4

shell init 6

shell processing 8

show shell environment 10

show shell functions 12

terminal shell 16

Cisco IOS Shell Command Reference iii

Page 4: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

Cisco IOS Shell Command Referenceiv

Contents

Page 5: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

A through Z Commands

• shell environment load, page 2

• shell environment save, page 4

• shell init, page 6

• shell processing, page 8

• show shell environment, page 10

• show shell functions, page 12

• terminal shell, page 16

Cisco IOS Shell Command Reference 1

Page 6: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

shell environment loadTo download Cisco IOS Shell (IOS.sh) environment from a specified file to the current TTY, use the shellenvironment loadcommand in privileged EXEC mode.

shell environment load filename:URL{merge| replace}

Syntax Description The URL of the shell environment file.filename:URL

Merge into the current shell environment.merge

Replace the current shell environmentreplace

Command Modes Privileged EXEC (#)

Command History ModificationRelease

This command was introduced.15.1(4)M

This command was integrated into Cisco IOS Release 15.1(2)S.15.1(2)S

This command was integrated into Cisco IOS Release 15.1(1)SG.15.1(1)SG

This command was integrated into Cisco IOS Release 15.1(1)SY.15.1(1)SY

Usage Guidelines Use the shell environment load command to download the Cisco IOS.sh environment from a specified fileto the current terminal. Use the shell environment save command to save this specific file prior to loadingthe file using the shell environment load command.

Examples This example shows how to save and then load a Cisco IOS.sh environment file and merge it into the currentshell environment :

Router> enableRouter# configure terminalRouter(config)#Enter configuration commands, one per line. End with CNTL/Z.Router(config)# shell processing fullRouter# exitRouter# shell environment save disk0:URLRouter# shell environment load disk0:URLmerge

Cisco IOS Shell Command Reference2

A through Z Commandsshell environment load

Page 7: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

Related Commands DescriptionCommand

Saves a Cisco IOS.sh environment functions to aspecific file.

shell environment save

Displays a Cisco IOS.sh environment information.show shell environment

Cisco IOS Shell Command Reference 3

A through Z Commandsshell environment load

Page 8: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

shell environment saveTo download Cisco IOS Shell (IOS.sh) environment from a specified file to the current TTY, use the shellenvironment loadcommand in privileged EXEC mode.

shell environment load filename:URL

Syntax Description The URL of the shell environment file.filename:URL

Command Modes Privileged EXEC (#)

Command History ModificationRelease

This command was introduced.15.1(4)M

This command was integrated into Cisco IOS Release 15.1(2)S.15.1(2)S

This command was integrated into Cisco IOS Release 15.1(1)SG.15.1(1)SG

This command was integrated into Cisco IOS Release 15.1(1)SY.15.1(1)SY

Usage Guidelines Use the shell environment save command to save all current shell environment, except built-in shell functions,to a specified file. Then only you can use theshell environment load command to load the Cisco IOS.shenvironment in the specific file on the current terminal.

Examples This example shows how to save a Cisco IOS.sh environment file:

Router> enableRouter# configure terminalRouter(config)#Enter configuration commands, one per line. End with CNTL/Z.Router(config)# shell processing fullRouter# exitRouter# shell environment save disk0:URL

Related Commands DescriptionCommand

Saves a Cisco IOS.sh environment functions to aspecific file.

shell environment save

Displays a Cisco IOS.sh environment information.show shell environment

Cisco IOS Shell Command Reference4

A through Z Commandsshell environment save

Page 9: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

Cisco IOS Shell Command Reference 5

A through Z Commandsshell environment save

Page 10: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

shell initTo enable Cisco IOS Shell (IOS.sh) initialization options, use the shell init command in global configurationmode. To disable the Cisco IOS.sh initialization options, use the no form of this command.

shell init {filename: no-exec}

no shell init

Syntax Description The URL of the shell environment file.filename:URL

Stores the initialization filename and loads the savedenvironment from that file at the next rebooting ofthe router.

no-exec

Command Default Cisco IOS.sh initialization is disabled.

Command Modes Global configuration (config)

Command History ModificationRelease

This command was introduced.15.1(4)M

This command was integrated into Cisco IOS Release 15.1(2)S.15.1(2)S

This command was integrated into Cisco IOS Release 15.1(1)SG.15.1(1)SG

This command was integrated into Cisco IOS Release 15.1(1)SY.15.1(1)SY

Usage Guidelines Use the shell initcommand to provide Cisco IOS.sh environment access to everyone who logs on to the router.If this command is configured, during system boot up, the router automatically reads and loads the contentof the shell configuration from the given file which includes the user-defined variables and functions createdpreviously. It copies the saved files into the Cisco IOS.sh environment. When you use the no-exec keyword,it allows you to store the initialization filename and loads the saved environment from that file at the nextrebooting of the router.

This command is similar to the show environment load command which allows you to download theCisco IOS.sh environment operations.

Note

Cisco IOS Shell Command Reference6

A through Z Commandsshell init

Page 11: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

Examples This example shows how to enable Cisco IOS.sh processing in all IOS modes:

Router# configure terminalEnter configuration commands, one per line. End with CNTL/Z.Router(config)# shell processing fullRouter(config)# shell init disk0:URL

Related Commands DescriptionCommand

Downloads a Cisco IOS.sh environment operations.show environment load

Cisco IOS Shell Command Reference 7

A through Z Commandsshell init

Page 12: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

shell processingTo restore the default behavior of Cisco IOS Shell (IOS.sh) processing, use the shell processing commandin global configuration mode. To disable the Cisco IOS.sh functions, use the no form of this command.

shell processing full

no shell processing

Syntax Description Enables shell processing.full

Command Default Cisco IOS.sh processing is enabled for other applications to use the shell functions.

Command Modes Global configuration (config)

Command History ModificationRelease

This command was introduced.15.1(4)M

This command was integrated into Cisco IOS Release 15.1(2)S.15.1(2)S

This command was integrated into Cisco IOS Release 15.1(1)SG.15.1(1)SG

This command was integrated into Cisco IOS Release 15.1(1)SY.15.1(1)SY

Usage Guidelines To enable shell processing and access all its functions, it is recommended that you use the shell processingfullcommand. This allows you the ability to use shell processing in the configuration level without enteringthe terminal shell command on your terminal at the EXEC level. Use the no shell processing command todisable Cisco IOS.sh processing on the router. To restore the default Cisco IOS.sh processing, use the shellprocessing command. To reenable shell processing and access all its functions, it is recommended that youuse the shell processing fullcommand.

You can turn shell processing on the terminal by using the terminal shellEXEC command. However shellprocessing feature is only on while the terminal is running. Once the terminal is turned off, shell processingis off. When the terminal shell command is used, shell processing is not visible in the running configurationbecause it is only on the terminal level and is not in the configuration level. It is convenient to use the terminalshell command at the terminal level to quickly access the Cisco IOS.sh man commands.

To enable shell processing and access all its functions in the configuration, it is recommended that you usethe shell processing full command.

Cisco IOS Shell Command Reference8

A through Z Commandsshell processing

Page 13: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

Examples This example shows how to enable Cisco IOS.sh processing in all Cisco IOS configuration modes:

Router> enableRouter# configure terminalEnter configuration commands, one per line. End with CNTL/Z.Router(config)# shell processing full

Related Commands DescriptionCommand

Enables Cisco IOS.sh functions on the router.terminal shell

Cisco IOS Shell Command Reference 9

A through Z Commandsshell processing

Page 14: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

show shell environmentTo display shell environment information about user-defined functions, built-in functions, and user-createdvariables, use the show shell environmentcommand in privileged EXEC mode.

show shell environment

Syntax Description This command has no arguments or keywords.

Command Modes Privileged EXEC (#)

Command History ModificationRelease

This command was introduced.15.1(4)M

This command was integrated into Cisco IOS Release 15.1(2)S.15.1(2)S

This command was integrated into Cisco IOS Release 15.1(1)SG.15.1(1)SG

This command was integrated into Cisco IOS Release 15.1(1)SY.15.1(1)SY

Usage Guidelines Use this command to display the shell variables used on the router.

Examples The following example displays both the shell environment variables and shell functions. Field names areself-explanatory

Router# show shell environment# Environment Variables:# User Environment Variables:?=0VAR1=value1VAR2=value2prc_change_mode=PRC_IMMEDIATEprc_change_type=PRC_CONFIG_CHANGEprc_error_code=PRC_SUCCESSprc_failure_type=PRC_INVALIDprc_ha_sync=PRC_HA_SYNC# Global Environment Variables:# Builtin Environment Variables:PATH=CLI%Userfunctions%Builtins%SYSTEM# Environment Functions:# User Environment Functions:Function namespace: DEFAULTfunction enable_archive(){configure terminalarchivepath disk0:backupwrite-memoryend}

Cisco IOS Shell Command Reference10

A through Z Commandsshow shell environment

Page 15: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

Function namespace: DEFAULTfunction enable_logging(){configure terminalarchivelogging enablerecord rcend}# Global Environment Functions:# Builtin Environment Functions:Function namespace: DEFAULT(( evaluate a numeric test expressionFunction namespace: DEFAULT[[ evaluate a logical test expressionFunction namespace: DEFAULTcat output data from a pipe or file to the terminalFunction namespace: DEFAULTcut edit piped outputFunction namespace: DEFAULTecho echo arguments to the terminalFunction namespace: DEFAULTfalse return false in while or if expressions, and set the resultFunction namespace: DEFAULTfetch return values from the configuration databaseFunction namespace: DEFAULTgrep search for regular expressions in piped output or filesFunction namespace: DEFAULThead print the first lines in the inputFunction namespace: DEFAULTinterface print interfaces that match the argumentFunction namespace: DEFAULTlet evaluate a numeric expression, and set the resultFunction namespace: DEFAULTman print information for builtinsFunction namespace: DEFAULTmore page piped output to the terminalFunction namespace: DEFAULTnl number the lines in the inputFunction namespace: DEFAULTnull ignore the inputFunction namespace: DEFAULTprintf output formatted data to the terminalFunction namespace: DEFAULTread read input into variablesFunction namespace: DEFAULTset_oper set operational valuesFunction namespace: DEFAULTsleep pause execution of the terminalFunction namespace: DEFAULTsort sort the inputFunction namespace: DEFAULTtail print the tail of the inputFunction namespace: DEFAULTtrue return true in while or if expressions, and set the resultFunction namespace: DEFAULTuname print system informationFunction namespace: DEFAULTwc count lines, words, and chars

Related Commands DescriptionCommand

Downloads Cisco IOS.sh environment from aspecified file to the current TTY.

shell environment load

Cisco IOS Shell Command Reference 11

A through Z Commandsshow shell environment

Page 16: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

show shell functionsTo display information about Cisco IOS Shell (IOS.sh) user-defined and built-in functions, use the show shellfunctions command in privileged EXEC mode.

show shell functions [functionname| brief]

Syntax Description (Optional) Specifies a user-defined shell function.functionname

(Optional) Lists the names of the user-defined andbuilt-in functions.

brief

Command Modes Privileged EXEC (#)

Command History ModificationRelease

This command was introduced.15.1(4)M

This command was integrated into Cisco IOS Release 15.1(2)S.15.1(2)S

This command was integrated into Cisco IOS Release 15.1(1)SG.15.1(1)SG

This command was integrated into Cisco IOS Release 15.1(1)SY.15.1(1)SY

Usage Guidelines Use this command to display the shell information for the router.

Examples The following example shows how to use the show shell functions privileged EXEC command to displaythe details of the user-defined and built-in functions. Field names are self-explanatory.

Router# show shell functions#User defined functions:Function namespace: DEFAULTfunction enable_archive(){configure terminalarchivepath disk0:backupwrite-memoryend}Function namespace: DEFAULTfunction enable_logging(){configure terminalarchivelogging enable

Cisco IOS Shell Command Reference12

A through Z Commandsshow shell functions

Page 17: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

record rcend}#Global User functions:#Built-in functions:Function namespace: DEFAULT(( evaluate a numeric test expressionFunction namespace: DEFAULT[[ evaluate a logical test expressionFunction namespace: DEFAULTcat output data from a pipe or file to the terminalFunction namespace: DEFAULTcut edit piped outputFunction namespace: DEFAULTecho echo arguments to the terminalFunction namespace: DEFAULTfalse return false in while or if expressions, and set the resultFunction namespace: DEFAULTfetch return values from the configuration databaseFunction namespace: DEFAULTgrep search for regular expressions in piped output or filesFunction namespace: DEFAULThead print the first lines in the inputFunction namespace: DEFAULTinterface print interfaces that match the argumentFunction namespace: DEFAULTlet evaluate a numeric expression, and set the resultFunction namespace: DEFAULTman print information for builtinsFunction namespace: DEFAULTmore page piped output to the terminalFunction namespace: DEFAULTnl number the lines in the inputFunction namespace: DEFAULTnull ignore the inputFunction namespace: DEFAULTprintf output formatted data to the terminalFunction namespace: DEFAULTread read input into variablesFunction namespace: DEFAULTset_oper set operational valuesFunction namespace: DEFAULTsleep pause execution of the terminalFunction namespace: DEFAULTsort sort the inputFunction namespace: DEFAULTtail print the tail of the inputFunction namespace: DEFAULTtrue return true in while or if expressions, and set the resultFunction namespace: DEFAULTuname print system informationFunction namespace: DEFAULTwc count lines, words, and charsThe following example shows how to use the show shell functions brief privileged EXEC command todisplay a list of the names of user-defined and built-in functions:

Router# show shell functions brief#User defined functions:enable_archiveenable_logging#Global User functions:#Built-in functions:(([[catcutechofalsefetchgrephead

Cisco IOS Shell Command Reference 13

A through Z Commandsshow shell functions

Page 18: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

interfaceletmanmorenlnullprintfreadset_opersleepsorttailtrueunamewc

Table 1: Built-in Cisco IOS.sh Functions

DescriptionBuilt-in Function

Output data from a pipe or file to the terminal.cat

Edit piped output.cut

Echo arguments to the terminal.echo

Return false in while or if expressions, and set theresult.

false

Return values from the configuration database.fetch

Cisco IOS.sh for loops.for

Search for regular expressions in piped output or files.grep

Print the first lines in the input.head

Print interfaces that match the argument.interface

Evaluate a numeric expression, and set the result.let

Print information for built-ins.man

Page piped output to the terminal.more

Number the lines in the input.nl

Ignore the input.null

Output formatted data to the terminal.printf

Read input into variables.read

Set operational values.set_oper

Cisco IOS Shell Command Reference14

A through Z Commandsshow shell functions

Page 19: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

DescriptionBuilt-in Function

Pause execution of the terminal.sleep

Sort the input.sort

Print the tail of the input.tail

Return true in while or if expressions, and set theresult.

true

Print system information.uname

Count lines, words, and chars.wc

The following example shows how to use the show shell functions enable_archive privileged EXEC commandto view the user-defined enable_archive function:

Router# show shell functions enable_archive#User defined functions:Function namespace: DEFAULTfunction enable_archive(){configure terminalarchivepath disk0:backupwrite-memoryend}

Cisco IOS Shell Command Reference 15

A through Z Commandsshow shell functions

Page 20: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

terminal shellTo enable Cisco IOS Shell (IOS.sh) functions on the router use the terminal shellcommand in privilegedEXEC mode. To disable Cisco IOS.sh functions, use the no form of this command.

terminal shell [trace]

terminal no shell

Syntax Description Turns on the trace feature on the shell functions thatprints the CLI as they are applied.

trace

Add trace if it is available [If the trace option is given, it will turn on the trace on the shell functions that printsthe CLI as they are applied.]

Command Modes Privileged EXEC (#)

Command History ModificationRelease

This command was introduced.15.1(4)M

This command was integrated into Cisco IOS Release 15.1(2)S.15.1(2)S

This command was integrated into Cisco IOS Release 15.1(1)SG.15.1(1)SG

This command was integrated into Cisco IOS Release 15.1(1)SY.15.1(1)SY

Usage Guidelines You can turn shell processing on the terminal by using the terminal shellcommand. However shell processingfeature is only on while the terminal is running. Once the terminal is turned off, shell processing is off. Whenthe terminal shell command is used, shell processing is not visible in the running configuration because it isonly on the terminal level and is not in the configuration level. It is convenient to use the terminal shellcommand at the terminal level to quickly access the Cisco IOS.sh man commands. To enable shell processingin the configuration, it is recommended that you use the shell processing fullcommand.

Examples The following examples shows how to enable Cisco IOS.sh functions on the router and enable the trace feature:

Router# terminal shellRouter# terminal shellRouter# terminal shell traceThe following examples shows how to disable Cisco IOS.sh functions on the router:

Router# terminal no shell

Cisco IOS Shell Command Reference16

A through Z Commandsterminal shell

Page 21: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

Related Commands DescriptionCommand

Enables Cisco IOS.sh processing on the router inglobal configuration mode.

shell processing full

Cisco IOS Shell Command Reference 17

A through Z Commandsterminal shell

Page 22: Cisco IOS Shell Command Reference · shell environment load ... uname print system information Function namespace: DEFAULT wc count lines, words, and chars Related Commands Command

Cisco IOS Shell Command Reference18

A through Z Commandsterminal shell