Support Support Downloads Knowledge Base Case Manager My Juniper Community

Knowledge Base

Search our Knowledge Base sites to find answers to your questions.

Ask All Knowledge Base Sites All Knowledge Base Sites JunosE Defect (KA)Knowledge BaseSecurity AdvisoriesTechnical BulletinsTechnotes Sign in to display secure content and recently viewed articles

[SRX] How to commit configuration changes via the shell

0

0

Article ID: KB25034 KB Last Updated: 23 Jun 2020Version: 2.0
Summary:

This article provides information about applying configurations via the shell.

 

Symptoms:

At times, when running a shell script, it is useful to apply the configuration changes.

 

Solution:

Perform the following steps:

  1. Create a sequence of the configuration commands that you wish to run line by line, as if they are starting via the CLI operational mode. End the sequence with a commit and send the echo output to /usr/sbin/cli, with the pipe separator, as shown in the following example:

root@old_name% cat testscript.sh 
echo "configure 
set system host-name new_name 
commit" | /usr/sbin/cli
  1. Run the script of your choosing and the commands, which were specified earlier, will be executed via configuration mode (because they were started with the configure command, which enters configuration mode). When the script ends, you will be returned to the shell:

root@old_name% sh testscript.sh
root@old_name> configure
Entering configuration mode

[edit]
root@old_name# set system host-name new_name

[edit]
root@old_name# commit
commit complete

[edit]
root@new_name#
root@old_name%
  1. In this case, you have to log out, and then log in to see the new name via the shell:

root@old_name% exit
logout
Connection to srx closed.
user@host:~$ ssh root@srx
root@srx's password:
--- JUNOS 10.4S4.2 built 2011-06-03 02:22:27 UTC
root@new_name%

 

Modification History:

2020-06-24: Article reviewed for accuracy; adjusted line 2 under "Solutions" to make it clearer; article still valid

 

Comment on this article > Affected Products Browse the Knowledge Base for more articles related to these product categories. Select a category to begin.

Getting Up and Running with Junos

Getting Up and Running with Junos Security Alerts and Vulnerabilities Product Alerts and Software Release Notices Problem Report (PR) Search Tool EOL Notices and Bulletins JTAC User Guide Customer Care User Guide Pathfinder SRX High Availability Configurator SRX VPN Configurator Training Courses and Videos End User Licence Agreement Global Search