Description

This article explains how to auto load and commit large set format commands via the shell script.
 

Solution

Example: Load and commit the following set format commands:

set routing-option static route 192.168.1.1 next-hop 1.1.1.1
set routing-option static route 192.168.1.2 next-hop 1.1.1.1
set routing-option static route 192.168.1.3 next-hop 1.1.1.1
set routing-option static route 192.168.1.4 next-hop 1.1.1.1
...
  1. Make a file under /var/tmp directory in your SRX device:

    % cd /cf/var/tmp
    % pwd
    /cf/var/tmp
    % touch set_commands.txt
  2. Paste the above set format commands into file set_commands.txt and save:

    % vi set_commands.txt
  3. File the following shell script under /cf/var/tmp:

    % cat configure_commit.sh
    #!/bin/sh
    echo "configure
    `cat set_commands.txt`
    commit" | /usr/sbin/cli
  4. % chmod u+x ./configure_commit.sh

  5. Run the shell script:

    % sh ./configure_commit.sh