Execute Batch File

Summary

This function allows you to prepare a file containing a series of commands (hereafter referred to as "batch file") on the external memory and execute them in a batch.

The download button can be configured to execute this function. The command execution results and logs are exported to the external memory as files. You can also perform this operation by executing the execute batch command from the console.

The following are examples of what you can achieve using this function:

  • PING for communication acknowledgment, etc. can be performed even in a PC-less environment.
    • The required equipment and work procedure can be greatly reduced during the router installation.
  • The execution results, settings, router statuses, etc. can be exported to the external memory as files.
    • You can remove the external memory and check the content on a mobile phone or use it as an operation log.

For more information on the basic usage of the external memory, button operations, LED/buzzer specifications and details of the SYSLOG messages, refer to "Using the External Memory".

Notes

You can execute the following commands using this function:

  • ping
  • ping6
  • Commands starting with "show -"
  • copy config
  • copy exec

You can also execute other commands, but they are not guaranteed to work correctly.

The following commands cannot be executed in this function:

  • administrator
  • cold start
  • exit
  • quit
  • Commands starting with "less -"
  • telnet
  • remote setup briN
  • execute batch
  • usbhost use
  • sd use
  • http revision-up go
  • netvolante-dns go
  • sshd host key generate
  • http upload go
  • Commands using a pipe "|" ("show log | grep ipsec", etc.)
  • Commands using an output to a file ">" ("show log > usb1:log.txt", etc.)

Compatible Models & Firmware Revisions

The Yamaha router models/firmware supporting the "Execute batch file" function are as described below.

Model Firmware
RTX5000 Rev.14.00.15 or later
FWX120 Rev.11.03.16 or later
RTX810 Rev.11.01.15 or later

Details

Prepare a Batch File

Save a batch file (a file containing multiple commands) to the external memory.
The file should be named "command.txt" and saved in text format.
You can change the file to be loaded using the "external-memory batch filename" command. To specify the file directly or change the file name using this command, refer to the descriptions below for more information.

In the batch file, describe one Yamaha router command per line and insert a line break at the end of each line.
Commands are interpreted line by line.
All strings not matching the supported commands are ignored as invalid commands and output to a log.
A string starting with "#" is treated as a comment.
Comments are also included in the exported log file.

The ping and ping6 commands work as described below.

  • ping
    The setting value for the -c option (execution count) is (1 to 10). The value is set to 10 if left empty.
    The setting value for the -w option (packet transmission interval in seconds) is (0.1 to 1.0). The value is set to 1.0 if left empty.

    The command will therefore be as shown below if the -c and -w options are both left empty.
    (Host: IP address or name of the host to be pinged)
    ping -c 10 -w 1 HOST
    
    This command pings the specified host 10 times in one-second intervals. If no response from the other party is acknowledged during the period from sending a packet until the next packet is sent, a "No ACK" message will be displayed.
  • ping6
    The setting value for the "count" parameter (number of transmissions) is (1 to 10). The value is set to 10 if left empty.

    The command will therefore be as shown below if the "count" parameter is left empty.
    (Host: Destination IPv6 address or name)
    ping6 HOST 10
    
    Pings the specified host 10 times in one-second intervals.

The following shows an example of a batch file:

# Batch file example 
show environment
show status lan1
show status pp 1 
ping 192.168.100.2 #Communication acknowledgment to the LAN
ping 192.168.0.1   #Communication acknowledgment to the remote branch 
show log 

Execute a Batch File

A batch file can be executed using the methods described below.

  • Press the DOWNLOAD button.
    • Configure the following commands such that pressing the DOWNLOAD button will execute a batch file:
      operation button function download execute batch
      operation execute batch permit on
      
    • Hold down the DOWNLOAD button for more than three seconds to execute the batch file.
      An alarm (one short beep) will sound and the DOWNLOAD lamp will blink slowly (*) at this time. The lamp will go off when the execution of all commands is complete.
    • An alarm (two short beeps) will sound when the execution of all commands described in the batch file is complete.
    • To abort the execution, press the DOWNLOAD button for more than one second.
    • The DOWNLOAD lamp will light if the execution ends with an error. (*)
      You can clear the error status by pressing the DOWNLOAD button for more than one second.

    (*) lighting/blinking of the DOWNLOAD lamp will not occur on models that do not have the DOWNLOAD lamp.

    • Execute the "execute batch" command.
      • An alarm (two short beeps) will sound when the execution of all commands described in the batch file is complete.
      • To abort the execution, press Ctrl + C.

Check the Execution Result

The execution results of the commands described in the batch file are output to the "command-log.txt" file in the directory in which the batch file is located.
You can change this file name using the "external-memory batch filename" command.

When the execution of the batch file is complete, press the external memory button for two seconds and remove the external memory after confirming that the external memory lamp has gone off. You can check the content of the execution result file on the removed external memory using a mobile phone or similar devices.

Execution Result File Example

The following data are exported to the execution result file:

  • Log data indicating that the batch file was executed
  • Commands that were executed from the batch file
  • Execution results of the commands executed from the batch file (Same as those displayed in the console)
  • Log data indicating the errors recorded when the batch file contained strings not matching the commands supported by this function

The execution result file for the following batch file is executed is provided as an example.

Batch file:
# Batch file example 
show environment
show status lan1
show status pp 1 
ping 192.168.100.2 #Communication acknowledgment to the LAN
ping 192.168.0.1   #Communication acknowledgment to the remote branch
show log
sd use off         #An example of a non-executable command 

Rename the Batch File and Log File

By default, the "command.txt" file is loaded from the external memory as the batch file. You can change this file name using the "external-memory batch filename" command.

Example: Load the "command_hoge.txt" file from the microSD memory card as a batch file.
# external-memory batch filename sd1:command_hoge.txt 

When you execute the batch file using the above settings example, the router will automatically search for the "command_hoge.txt" file on the microSD card and execute the commands described in the file. If you know the exact file location, you can reduce the search time by directly specifying the location using an absolute path. For details about the automatic file search, refer to the information in "Using the External Memory".

The execution result log file is saved with the file name "(Batch file name)-log.txt" in the directory in the external memory where the batch file is located. If you use the settings in the example above, a log file called "command_hoge-log.txt" will be created in the directory containing the "command_hoge.txt" file on the microSD card.

You can also change the name of the log file using this command.

Example: Load the "command_hoge.txt" file from the microSD card as the batch file and output the result to the "command.log" file.
# external-memory batch filename sd1:command_hoge.txt command.log 

If you execute the batch file in the above setting example, the commands described in the "command_hoge.txt" file will be executed. The execution result will then be output to a file called "command.log" in the same directory as the "command_hoge.txt" file.

Special Notes

  • If an execution result file with the same name already exists in the external memory, the execution result will be appended to the end of the existing file.
  • When no more results can be appended, the execution result file will not be overwritten and no more appending will occur. Delete the existing files as required to allocate sufficient memory space.
  • If you execute commands using a batch file, the device name output to the SYSLOG will be "GENERAL".
    Example: If you execute the "save" command
    Configuration saved in "CONFIG0" by GENERAL

Command

Execute the Batch File

[Syntax]
execute batch
[Description]

Executes the batch file in the external memory. You can specify the name of the batch file to execute using the "external-memory batch filename" command.

[Note]

If you want to stop the execution of a batch file, enter Ctrl+C.

[Applicable Models]
RTX5000 RTX810 FWX120

Set the Batch and Execution Result Files

[Syntax]
external-memory batch filename BATCHFILE [LOGFILE]
no external-memory batch filename [BATCHFILE [LOGFILE]]
[Setting Value]
  • BATCHFILE ...... Batch file name
    • usb1:FILENAME .... A batch file in the USB memory
    • sd1:FILENAME .... A batch file in the microSD card
    • *:FILENAME .... A batch file in the USB memory or microSD card
  • LOGFILE
    • FILENAME .... The name of the execution result file
[Initial Value]
  • BATCHFILE
    • *:command.txt (RTX810, FWX120)
    • sd1:command.txt (RTX5000)
  • LOGFILE
    • command-log.txt
[Description]

Specifies the names of the batch file and the execution result file on the external memory.

If you use an asterisk to specify the external memory, the router starts searching the microSD card for the specified file. If the router can't find the file on the memory card, it searches for it in the USB memory.

You can specify the FILENAME parameter with an absolute path or a file name. If you only specify a file name for the FILENAME parameter, the router will automatically search through the external memory for the file. If the router finds multiple files, it chooses the file in the directory that is closest to the root directory and first in alphabetical order.

If you omit the LOGFILE parameter, the router creates an execution result file with the name (batch file name)-log.txt.

[Note]

when LOGFILE is specified, the number of characters that can be specified for BATCHFILE is up to 99 characters. When LOGFILE is omitted, the number is up to 91 characters excluding an extension. The number of characters that can be specified for FILENAME is up to 99 characters.

[Example]
  • Search for the "command_test.txt" file on the microSD card and use it as the batch file.
    # external-memory batch filename sd1:command_test.txt
  • Load "command_test.txt" from the "test" directory on the microSD card.
    # external-memory batch filename sd1:/test/command_test.txt
[Applicable Models]
RTX5000 RTX810 FWX120

Set the Function to Execute When the DOWNLOAD Button Is Pressed

[Syntax]
operation button function download FUNCTION [SCRIPT_FILE [ARGS ...]]
no operation button function download [FUNCTION [SCRIPT_FILE [ARGS ...]]]
[Setting Value]
  • FUNCTION ...... The function to execute when the DOWNLOAD button is pressed
    • http revision-up .... HTTP revision update
    • execute batch .... Batch file execution
    • mobile signal-strength .... Acquisition of the signal reception level of a mobile terminal
    • execute lua .... Lua script execution
  • SCRIPT_FILE ...... Specify the absolute or relative path of a script file or bytecode file.
  • ARGS ...... The variable arguments to pass to SCRIPT_FILE.
[Initial Value]
  • FUNCTION ... http revision-up
[Description]

Sets the function that is executed when the DOWNLOAD button is pressed. While the function is being executed, the LED below the DOWNLOAD button lights. The LED turns off when the execution of the function is completed.

If you set the FUNCTION parameter to execute lua, you must specify a file for the SCRIPT_FILE parameter. If you set SCRIPT_FILE to a relative path, it is interpreted as a path starting with the PWD environment variable. You can change PWD with the "set" command. Its initial value is "/".

[Note]

When you execute a Lua script, if the LUA_INIT environment variable has been specified, it will be executed before the file specified by the SCRIPT_FILE parameter.

[Applicable Models]
RTX810 FWX120

Set Whether to Allow Batch File Execution through the Pressing of the DOWNLOAD Button

[Syntax]
operation execute batch permit PERMIT
no operation execute batch permit [PERMIT]
[Setting Value]
  • PERMIT
    • on .... Allow batch file execution through the pressing of the DOWNLOAD button
    • off .... Do not allow batch file execution through the pressing of the DOWNLOAD button
[Initial Value]
  • off
[Description]

Sets whether to allow batch file execution through the pressing of the DOWNLOAD button.

[Initial Value]

off

[Applicable Models]
RTX810 FWX120

Return to Top