Attaching files to a script and receiving files generated by script
Running certain script commands requires sending or receiving files to or from firewalls. For example:
- Updating firewalls,
- Installing licenses,
- Generating backups of firewall configurations.
Files can be sent or received from the web interface of the SMC server and from the command line interface.
For a command requiring an input file, use the following command arguments to specify the name of the file to be sent:
-
$FROM_DATA_FILE("myFileName.extension")
to attach a file without Unicode processing, -
$FROM_TEXT_FILE("myFileName.extension")
to attach a file with Unicode processing.
For a command generating an output file, use the following command arguments to specify the name of the file to be received:
-
$SAVE_TO_DATA_FILE("myFileName.extension")
to back up a file without Unicode processing, -
$SAVE_TO_TEXT_FILE("myFileName.extension")
to back up a file with Unicode processing.
To find out the locations of these files, please refer to the sections below Attaching files to a SNS CLI script and Receiving files generated by a SNS CLI script.
The script will not run if:
- No files have been specified in the argument of a command that requires an input file or generates an output file,
- An input or output file has been specified in the argument of a command that does not require one.
Example
The following command makes it possible to generate the backup file of a firewall named backup-22-09-16.na on the SMC server:
CONFIG BACKUP list=all $SAVE_TO_DATA_FILE("backup-22-09-2016.na")
You can use variables in the syntax for sending or receiving files. For example, to create configuration backups for several firewalls, write the following command:
CONFIG BACKUP list=all $SAVE_TO_DATA_FILE("backup-%FW_NAME%.na")
In both of the following cases, the attached files will be deleted from the SMC server after the script has been successfully executed.
Via the web interface
- In the web interface of the SMC server, select Deployment > SNS CLI scripts.
- In the Firewall selection tab, after you have selected a script, select one or several attachments from the sub-menu Attachments related to scripts.
Via the command line interface
Copy the attachments at the root of the folder /data/tmp/sns-cli/input on the SMC server using SSH.
The script execution engine retrieves the files needed at this location in order to forward them to the firewalls.
TIP
You can change the default folder in the environment variable SMC_SNS_CLI_ATTACHMENTS_DIR
located in the file /data/config/fwadmin-env.conf.local. You will then need to restart the server: nrestart smc
.
Via the web interface
In the Execution tab in the SNS CLI scripts menu, retrieve all files and logs generated for each firewall the last time the script was run.
To retrieve files and logs generated in earlier script executions, refer to the following section Via the command line interface.
Receiving files and logs
Click on Download all generated files at the bottom of the Execution tab to download an archive that includes all generated files and execution logs for all firewalls at the same time. The archive will contain a folder per firewall.
To retrieve files and logs generated by running a script on a single firewall, click on the icon in the column Generated files.
Reading execution logs
To simply read execution logs for a given firewall, click on the icon in the column Generated files.
Via the command line interface
All files and logs generated for each firewall after running a script are saved by default in the folder /data/tmp/sns-cli/output on the SMC server. The tree created as such will contain a folder for each script execution.
TIP
You can change the default folder in the environment variable SMC_SNS_CLI_OUTPUT_DIR
located in the file /data/config/fwadmin-env.conf.local. You will then need to restart the server: nrestart smc
.
Example
When this command is run
CONFIG BACKUP list=all $SAVE_TO_DATA_FILE("backup-%FW_NAME%.na")
the following tree is obtained:
/data/tmp/sns-cli/output/latest -> 00001_20160219-171926
/data/tmp/sns-cli/output/00001_20160219-171926
/data/tmp/sns-cli/output/00001_20160219-171926/sns-2
/data/tmp/sns-cli/output/00001_20160219-171926/sns-1/backup-sns-2.na
/data/tmp/sns-cli/output/00001_20160219-171926/sns-2/output.log
/data/tmp/sns-cli/output/00001_20160219-171926/sns-1
/data/tmp/sns-cli/output/00001_20160219-171926/sns-1/backup-sns-1.na
/data/tmp/sns-cli/output/00001_20160219-171926/sns-1/output.log
The latest folder always directs to the last execution.