< Home

execute

Function

The execute command executes a specified batch file.

Format

execute batch-filename

Parameters

Parameter Description Value
batch-filename

Specifies the name of a batch file.

batch-filename supports file name association. The disk and directory where the file resides can be automatically associated.
  • Full help: All the disks of the device can be associated and displayed.
  • Partial help: The related disk, directory, and file can be associated and displayed after you enter a specified character string.
The value is a string of 5 to 160 case-insensitive characters without spaces. The file name extension is .bat.

Views

System view

Default Level

3: Management level

Usage Guidelines

Usage Scenario

If a series of commands are frequently executed, write these commands in a batch file, and store this file in system. In this way, you can only execute this command to run multiple commands which were manually entered before. This command improves maintenance and management efficiency.

  • The batch file is edited in .txt format. When editing the file, ensure that one command occupies one line. After editing the file, save the file and change the file name extension to .bat.

  • Transfer the batch file in file transmission mode to the device.

Prerequisites

Before running the execute command, ensure that the batch file to be processed is in the current directory; otherwise, the system cannot find the batch file.

Precautions

  • The commands in a batch file are run one by one. A batch file cannot contain invisible characters (control characters or escape characters, such as \r, \n, and \b). If any invisible character is detected, the execute command exits from the current process and no rollback is performed.

  • The execute command does not ensure that all commands can be run. If the system runs a wrong or immature command, it displays the error and goes to next command. The execute command does not perform the hot backup operation, and the command format or content is not restricted.

  • In case of interactive commands, batch file execution waits the device to interact with users before continuing.

When processing files in batches, add the echo off field in the first line to mask command line prompts. After the echo off field is added, the command line prompts and command lines are not displayed when command lines are processed in batches. Comply with the following rules:

  • The echo off field can be added only to the first line of the files to be processed in batches.
  • The echo off field is case-insensitive.
  • The line where the echo off field resides cannot contain any special characters, spaces excluded.

In the batch file, you can enter wait(time) between commands to set a command execution delay. The value of time ranges from 1 to 1800, in seconds. For example, wait(10) indicates that the next command is executed 10 seconds later. The value of wait(time) is case-insensitive. In the line where wait(time) resides, spaces cannot be placed before or after wait(time), or before or after time. Other characters are also not allowed.

Example

# Execute the test.bat file in the directory flash:/. The test.bat file contains three commands: system-view, aaa, and local-user huawei password irreversible-cipher Helloworld@6789.

<HUAWEI> system-view
[HUAWEI] execute test.bat
[HUAWEI]
         ^
Error: Unrecognized command found at '^' position.
[HUAWEI]
[HUAWEI-aaa]
 Info: Add a new user 
[HUAWEI-aaa]

When the system runs the first command system-view in current system view, it displays an error and continues to run the following commands.

The system displays the execution of a batch file in AAA view.

[HUAWEI-aaa] display this 
 local-user huawei password irreversible-cipher $1a$HW=5%Mr;:2)/RX$FnU1HLO%-TBMp4wn%;~\#%iAut}_~O%0L$
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >