Support Support Downloads Knowledge Base Apex Support Portal 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

[ScreenOS] How to Run a Script on the Firewall

0

0

Article ID: KB10219 KB Last Updated: 01 Sep 2020Version: 5.0
Summary:
I need to run a script that would obtain a series of get commands.  This script would be run automatically. 
Requires ScreenOS 6.0.0 and higher.
Solution:
The 'scripting feature' is supported on any firewall device that is running ScreenOS 6.0.0 and higher.  With this feature, you can record a series of 'get' commands, and have it run a number of times.  You can then see the output after the script has completed its run.  This feature is only supported from the CLI, and only supports 'get' commands (run from either the console, telnet, or SSH).

Here is the procedure:
  1. Login to the device via the console, telnet, or SSH
  2. Run the command 'set script record'
  3. Enter the desired commands to run during the script.
  4. Stop the recording of commands by running the command 'exit record'
  5. Run the script with the command 'exec script frequency 5'.  This will execute the script every 5 seconds
  6. Stop the script with the command 'exec script stop'
  7. To obtain the output of the script, issue the command 'get script'

Here is an example:

The following commands will create a script with the commands 'get clock' and 'get sess info'.
 
ssg-> set script record
ssg(sgc: recording)-> get clock
ssg(sgc: recording)-> get sess info
ssg(sgc: recording)-> exit record
ssg->

The following command will execute the script once every 5 seconds, until you tell the script to stop. 
 
ssg-> exec script start frequency 5
ssg->

Note:  There is an option for 'exec script start count 5', however, this is not as intuitive as you would think.  When you use the count feature, it will run the script once every 3600 seconds, until the count has been reached.  For example, if you specify the script count as 5, it will run the script once every hour, for 5 hours, then stop. 

To view the status of the script, run the command 'get script':
 
ssg-> get script
Script status: running
  Wrap: Yes
  Frequency: 5 Sec.
  Runs: 4
  Max file size: 100 (k)
ssg->

This reports that the script has run 4 times, once every 5 seconds.

To view the output of the script that was just run, enter the command 'get script output':
 
ssg-> get script output
File size:3941
  Wrap : Yes
  Count: No
  Runs : 5
  Max file size: 100 (k)
Script output:
********** Script start ********** 11/18/2007 09:00:54 **********
<<<<<<<<<< get clock >>>>>>>>>> 11/18/2007 09:00:54
Date 11/18/2007 09:00:54, Daylight Saving Time enabled
The Network Time Protocol is Enabled
Up 135 hours 39 minutes 35 seconds Since 12Nov2007:17:21:19
1195376454.200267 seconds since 1/1/1970 0:0:0 GMT
GMT time zone area -8:00
GMT time zone offset 8:00
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<<<<<<<<<< get sess info >>>>>>>>>> 11/18/2007 09:00:54
alloc 40/max 8064, alloc failed 0, mcast alloc 0, di alloc failed 0
total reserved 0, free sessions in shared pool 8024
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
********** Script end ********** 11/18/2007 09:00:54 ************

********** Script start ********** 11/18/2007 09:00:59 **********
<<<<<<<<<< get clock >>>>>>>>>> 11/18/2007 09:00:59
Date 11/18/2007 09:00:59, Daylight Saving Time enabled
The Network Time Protocol is Enabled
Up 135 hours 39 minutes 40 seconds Since 12Nov2007:17:21:19
1195376459.335153 seconds since 1/1/1970 0:0:0 GMT
GMT time zone area -8:00
GMT time zone offset 8:00
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<<<<<<<<<< get sess info >>>>>>>>>> 11/18/2007 09:00:59
alloc 33/max 8064, alloc failed 0, mcast alloc 0, di alloc failed 0
total reserved 0, free sessions in shared pool 8031
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
********** Script end ********** 11/18/2007 09:00:59 ************

********** Script start ********** 11/18/2007 09:01:05 **********
<<<<<<<<<< get clock >>>>>>>>>> 11/18/2007 09:01:05
Date 11/18/2007 09:01:05, Daylight Saving Time enabled
The Network Time Protocol is Enabled
Up 135 hours 39 minutes 46 seconds Since 12Nov2007:17:21:19
1195376465.486924 seconds since 1/1/1970 0:0:0 GMT
GMT time zone area -8:00
GMT time zone offset 8:00
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<<<<<<<<<< get sess info >>>>>>>>>> 11/18/2007 09:01:05
alloc 35/max 8064, alloc failed 0, mcast alloc 0, di alloc failed 0
total reserved 0, free sessions in shared pool 8029
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
********** Script end ********** 11/18/2007 09:01:05 ************

********** Script start ********** 11/18/2007 09:01:10 **********
<<<<<<<<<< get clock >>>>>>>>>> 11/18/2007 09:01:10
Date 11/18/2007 09:01:10, Daylight Saving Time enabled
The Network Time Protocol is Enabled
Up 135 hours 39 minutes 51 seconds Since 12Nov2007:17:21:19
1195376470.638136 seconds since 1/1/1970 0:0:0 GMT
GMT time zone area -8:00
GMT time zone offset 8:00
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<<<<<<<<<< get sess info >>>>>>>>>> 11/18/2007 09:01:10
alloc 33/max 8064, alloc failed 0, mcast alloc 0, di alloc failed 0
total reserved 0, free sessions in shared pool 8031
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
********** Script end ********** 11/18/2007 09:01:10 ************

********** Script start ********** 11/18/2007 09:01:15 **********
<<<<<<<<<< get clock >>>>>>>>>> 11/18/2007 09:01:15
Date 11/18/2007 09:01:15, Daylight Saving Time enabled
The Network Time Protocol is Enabled
Up 135 hours 39 minutes 56 seconds Since 12Nov2007:17:21:19
1195376475.790018 seconds since 1/1/1970 0:0:0 GMT
GMT time zone area -8:00
GMT time zone offset 8:00
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<<<<<<<<<< get sess info >>>>>>>>>> 11/18/2007 09:01:15
alloc 32/max 8064, alloc failed 0, mcast alloc 0, di alloc failed 0
total reserved 0, free sessions in shared pool 8032
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
********** Script end ********** 11/18/2007 09:01:15 ************

ssg->
Modification History:
2020-09-01: Article reviewed for accuracy; minor non-technical changes done.
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