How to create quick scripts using the CLI

For those of you who are too lazy or just simply don’t feel like learning another scripting language, I show you how to get any script you want for the Fortigate units using the CLI. We are going to use the Diagnose Debug branch commands in order to accomplish this.

You will need an SSH client to do this. [Ex. Putty]

1. Start an SSH session to your box.
2. Run > Diag debug enable
3. Run > Diag debug cli 7
4. Now just keep this window open and log into the GUI and make changes to your config that you would like scripted.
This will allow all changes made in the gui to output the corresponding CLI commands in your SSH client.

In order to make this into a usable script you will have to copy the script into a text file and edit out the “O: ” that precedes the commands.

I hope that you have found this useful. 🙂
(c) http://www.fortihelp.com/

(246)